URL中的乱码转中文
[string stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
ios 7.0以上的barButtonItem设置
UIButton *leftButton=[UIButton buttonWithType:UIButtonTypeCustom];
[leftButton setFrame:CGRectMake(0, 0, 40, 40)];
[leftButton setImage:[UIImage imageNamed:@"nav_back"] forState:UIControlStateNormal];
[leftButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *leftItem=[[UIBarButtonItem alloc]initWithCustomView:leftButton ];
if(([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0?20:0)){
UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil action:nil];
negativeSpacer.width = -17;
self.navigationItem.leftBarButtonItems = @[negativeSpacer, leftItem];
}else
{
self.navigationItem.leftBarButtonItem=leftItem;
}
不使用xib和storyboard时的init
tableViewCell:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
//subviews的生成方法
}
return self;
}
viewController:
- (instancetype)init
{
if (!(self = [super init]))
return nil;
//添加subView的生成
return self;
}
Mac快捷键
例如:~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/
小贴士:用 cmd+shift+g 快速查找;如果没有 Plug-ins 目录,你得创建一个