手机版
网站地图
美文美图
最新动态
你好,欢迎访问
好美文阅读网
个性皮肤
搜索
网站首页
美文
文章
散文
日记
诗歌
小说
故事
句子
作文
签名
祝福语
情书
范文
读后感
文学百科
美文摘抄
节日文章
名家散文
网名大全
座右铭
口号大全
面试技巧
说说大全
阅读答案
诗词默写
流言蜚语
节日祝福
好句子
经典台词
谚语大全
亲情故事
友情故事
表白情书
工作报告
活动总结
心得体会
专题汇总
美文网首页
今天分享一些常见的代码块
今天分享一些常见的代码块
作者:
JarodWang
| 来源:发表于
2018-04-08 16:57 被阅读22次
代码块,小伙伴们应该都知道,自己定义一些繁杂又多又不想敲得代码块,使用起来就直接敲一到两个字回车就OK。酱紫方便了不知道多少对吧,在下技术一般大佬们看到自动忽略写得不好勿喷,多多指教。
废话不多说进入正题
选中自己想要添加的代码,然后鼠标别移动点击你当前选中的代码大概一到两秒鼠标变成小箭头的时候拖到这里
1.afterGCD
上面这个图是教各位怎么填写里面的东西
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(<#delayInSeconds#> * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
<#code to be executed after a specified delay#>
});
上面的这张图是为了让大家看看怎么填写这些东西。方便使用下面的就不上图了直接上代码
2.保证整个工程中只执行一次得OnceGCD
staticdispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
<#code to be executed once#>
});
3.MainGCD
dispatch_async(dispatch_get_main_queue(), ^{
<#code#>
});
4.声明属性的assign
/**
<#Description#>
*/
@property(nonatomic,assign)<#type#> <#value#>;
5.声明属性的block
/**
<#Description#>
*/
@property(nonatomic,copy) <#Block#> <#block#>;
6.声明属性的代理
/**
<#Description#>
*/
@property(nonatomic,weak)id<<#protocol#>> <#delegate#>;
7.声明属性的strong
/**
<#Description#>
*/
@property(nonatomic,strong) <#Class#> *<#object#>;
8.cell当然需要在代理方法内部直接调用就可
staticNSString *rid=<#rid#>;
<#Class#> *cell=[tableView dequeueReusableCellWithIdentifier:rid];
if(cell==nil){
cell=[[<#Class#> alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:rid];
}
return cell;
9.简单的按钮不带img的连带方法参上
UIButton * <#object#> = [UIButton buttonWithType:UIButtonTypeCustom];
<#object#> .backgroundColor = <#UIColor#>;
<#object#> .titleLabel.font = <#UIFont#>;
[<#object#> setTitleColor:<#UIColor#> forState:UIControlStateNormal];
<#object#> .userInteractionEnabled =YES;
<#object#> .selected =NO;
[ <#object#> setTitle:<#value#> forState:UIControlStateNormal];
[btn addTarget:selfaction:@Selector(<#methodName#>) forControlEvents:UIControlEventTouchUpInside];
[<#UIView#> addSubView:<#Object#>];
-(void)<#methodName#>:(<#btnClassName#> *)sender{ }
10.简单的textField
UITextField * <#object#> = [[UITextField alloc] init];
<#object#>.font = <#UIFont#>;
<#object#>.placeholder = <#placeholdStr#>;
<#object#>.textColor = <#UIColor#>;
<#object#>.backgroundColor = <#UIColor#>;
[<#UIView#> addSubView:<#object#>];
11.简单的label
UILabel * <#object#> = [[UILabel alloc] init];
<#object#> .backgroundColor = <#UIColor#>;
<#object#> .textColor = <#UIColor#>;
<#object#> .font = <#UIFont#>;
<#object#> .text = <#NSSting#>;
<#object#> .textAlignment = <#NSTextAlignment#>;
[<#UIView#> addSubView: <#object#> ];
12.简单的img
UIImageView * <#object#> = [[UIImageView alloc] init];
<#object#>.image = [UIImage imageNamed:<#imgStr#>];
[<#UIView#> addSubView:<#object#>];
13.下拉刷新,当然注意这是refresh控件的
/**
下拉刷新
*/
-(void)dropDownRefresh{
__weak typeof(self) weakSelf = self;
[<#object#> addLegendHeaderWithRefreshingBlock:^{
int64_t delayInSeconds = <#value#>;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
[weakSelf.<#object#>.legendHeader beginRefreshing];
[weakSelf.<#object#>.legendHeader endRefreshing];
});
}];
}
14.上拉加载
/*
上拉加载
*/
-(void)pullUpLoad{
self.page =0;
__weak typeof(self) weakSelf = self;
[<#object#> addLegendFooterWithRefreshingBlock:^{
weakSelf.page +=1;
int64_t delayInSeconds = <#value#>;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
});
}];
}
好啦暂时就分享到这里啦,本文原创转载请注明出处。另外本文仅做分享技术,不做商业用途。如有雷同尽情谅解。
如果觉得可以点个赞~~你们的赞就是我的动力哈~!
相关文章
网友评论
本文标题:
今天分享一些常见的代码块
本文链接:
https://www.haomeiwen.com/subject/iehmhftx.html
延伸阅读
那年盛夏诗歌
环境监察队工作总结范文
优秀教师学习心得范文
华胥引的读后感300字
《Its red》教学反思范文
农资购销的合同范本
竞选中队委优秀演讲稿
辞金蹈海的成语解释
《世纪宝鼎》公开课教案设计
因为爱你,所以牵挂
今生今世红尘醉——美到
一个90后的内心独白
致已逝去的高中年华
深度阅读
您也可以注册成为美文阅读网的作者,发表您的原创作品、分享您的心情!
情人节
母亲节
重阳节
清明节
端午节
植树节
元宵节
妇女节
愚人节
圣诞节
父亲节
教师节
儿童节
劳动节
青年节
建军节
万圣节
平安夜
光棍节
中秋节
国庆节
感恩节
腊八节
更多话题
栏目导航
摄影
故事
互联网
读书
旅行
热点阅读
你不是四月天
远见卓识
springboot入门之路(一)
Tabelog发布2018日本最佳餐厅榜单 | 日本人想吃一辈子
春天老了吗?(15)
我喜欢拍照,不是为了炫耀
2018-04-08 iOS开发历程(一)
新模式新担当 2018 • 龙易配货主版新版本发布会圆满落幕
如何让孩子心甘情愿写作业?
理想与现实的虚虚实实
网友评论