代碼塊,小伙伴們應該都知道,自己定義一些繁雜又多又不想敲得代碼塊,使用起來就直接敲一到兩個字回車就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.保證整個工程中只執行一次得OnceGCDstaticdispatch_once_t onceToken;dispatch_once(&onceToken, ^{? ? <#code to be executed once#>?});3.MainGCDdispatch_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){? ? ? ? });? ? }];}好啦暫時就分享到這里啦,本文原創轉載請注明出處。另外本文僅做分享技術,不做商業用途。如有雷同盡情諒解。如果覺得可以點個贊~~你們的贊就是我的動力哈~!