iOS快捷代码块
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了iOS快捷代码块,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2315字,纯文字阅读大概需要4分钟。
内容图文
![iOS快捷代码块](/upload/InfoBanner/zyjiaocheng/1060/14643905838c468c841ef6841c18d238.jpg)
定义宏进行懒加载!!!!!!!!!!!!
#define ArrayLazyLoad(x) if (!x) { x = [NSMutableArray new];}return x
常量 和局部变量 block 中需要用__block修饰才可以在block内部修改它的值,全局变量和全局常量变量不用修饰
循环引用是自定义的block才会造成,系统的不会 归根结底还是堆栈中的释放问题.
懒加载!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!1!!!!!!!!!!!
/**<#懒加载#>*/
- (<#类名#>)<#变量名#> {
if (_<#变量名#> == nil) {
_<#变量名#> = [[<#类名#> alloc]init];
}
return _<#变量名#>;
}
匿名类!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
@interface <#类名#> ()
/** <#名字#> */
@property (nonatomic ,<#assign#>)<# NSString#> * <#name#>;
@end
表格视图快捷块!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/**创建表格试图*/
UITableView * table = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];
table.dataSource = self;
table.delegate = self;
[self.view addSubview:table];
self.tableView = table;
属性快捷块!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/** <#名字#> */
@property (nonatomic ,<#assign#>) <#NSString#> * <#name#>;
警告框快捷块!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/**<#警告弹出#>*/
UIAlertController * alert = [UIAlertController alertControllerWithTitle:<#@"弹出警告"#> message:<#@"警告信息"#> preferredStyle:UIAlertControllerStyl<#eAlert#>];
UIAlertAction * action = [UIAlertAction actionWithTitle:<#@"go"#> style:UIAlertActionStyl<#eDefault#> handler:^(UIAlertAction *action) {
}];
[alert addAction:action];
[self presentViewController:alert animated:YES completion:nil];
监听中心快捷块!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
/**<#创建监听中心#>*/
//写在方法中
[[NSNotificationCenter defaultCenter]addObserver:<#self#> selector:@selector(<#keyboardNotice:#>) name:<#UIKeyboardWillShowNotification#> object:nil];
[[NSNotificationCenter defaultCenter]addObserver:<#self#> selector:@selector(<#keyboardNotice:#>) name:<#UIKeyboardWillHideNotification#> object:nil];
- (void)keyboardNotice:(NSNotification*)notice {
if ([notice.name isEqualToString:<#UIKeyboardWillShowNotification#>]) {
self.view.bounds = CGRectMake(0, 100, self.view.bounds.size.width, self.view.bounds.size.height);
}else if ([notice.name isEqualToString:<#UIKeyboardWillHideNotification#>]){
self.view.bounds = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
}
}
原文:http://www.cnblogs.com/zhang6332/p/6273351.html
内容总结
以上是互联网集市为您收集整理的iOS快捷代码块全部内容,希望文章能够帮你解决iOS快捷代码块所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。