程序小细节

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 目录,你得创建一个

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 有时候,把一个人想得太好,把一切都幻想成自己想要的样子。然后自己骗自己,幻想你们有无数种可能。其实你早已知道,你...
    橘色余生阅读 189评论 0 0
  • 有时候抬头看云 难以名状 变化无常 就像你我
    若为你执骨阅读 125评论 0 1