xib和storyboard的使用方法

initWithNibName加载xib或者storyboard

// VC

BLEViewController *controller = [[BLEViewController allocinitWithNibName:@"BLEViewController" bundle:nil];

// VIEW

cell =  [[[ NSBundle mainBundle loadNibNamed : @"cell" owner : nil options : nil lastObject];// name,不带.xib

 

当出现错误:setValue:forUndefinedKey:一般都是xib或者storybord连线的问题

 http://www.bubuko.com/infodetail-657494.html

找到该controller,右键查看某个控件关联的属性 ,删掉之前一个项目的所有连线(注意这里有黄色警告的地方都是),重新编译运行即可

用xib,不会调用init,而调用awakeFromNib。

图标改圆角显示。 在awakeFromNib方法中用_iconView.layer.cornerRadius = 8;_iconView.layer.maskToBounds = YES;(让内部的所有图层都遵循父图层的边框来显示,超出父图层的内容不显示,被裁减掉。或者将这句改成_iconView.clipsToBounds = YES;)

 

 

原文地址:https://www.cnblogs.com/dengchaojie/p/4743360.html