ios小知识点积累

1,设置edgesForExtendedLayout=UIRectEdgeNone时会导致navigationbar和tarbar背景出现一条灰色的背景。解决办法:设置Translucent属性。代码:

self.navigationController.navigationBar.translucent=NO;

self.tabBarController.tabBar.translucent=NO;


2,textfield设置左右图片

UITextField*textField=[[UITextFieldalloc]init];

UIImageView*imgv=[[UIImageViewalloc]initWithImage:[UIImageimageNamed:@"right.png"]];

textField.rightView=imgv;

textField.rightViewMode=UITextFieldViewModeAlways;


3,

obj转json

NSData* jsonData = [NSJSONSerializationdataWithJSONObject:detailDicoptions:0error:nil];

NSString* myString = [[NSStringalloc]initWithData:jsonDataencoding:NSUTF8StringEncoding];

json转obj

NSDictionary* selectSimpleTest = [NSJSONSerializationJSONObjectWithData:[tizhiSimpleTest.detaildataUsingEncoding:NSUTF8StringEncoding]options:0error:nil];



4,归档解档保存本地数据

[NSKeyedArchiver archiveRootObject:obj toFile:filePath]//写

 [NSKeyedUnarchiver unarchiveObjectWithFile:filePath];//读

你可能感兴趣的:(ios小知识点积累)