iOS快捷代码块

//数据请求

/**<#封装数据请求(只适用本人)#>*/

 

NSString * requestUrl = [NSString stringWithFormat:@"%@%@",<#服务#>,<#地址#>];

 

NSMutableDictionary * parameterDic = [[NSMutableDictionary alloc]init];

 

[parameterDic setObject:<#@"1"#> forKey:<#@"page"#>];

 

[[ZJHAfnManager sharedManager] request<#POST#>WithPath:requestUrl parameters:parameterDic submittingToken:<#YES#> showHUDToView:<#self.view#> success:^(ZJHModelResponse *response) {

    

    if ([response.code isEqualToString:<#@"100"#>]) {

        

        [MBProgressHUD showSuccess:response.reason];

        

    }else {

        [MBProgressHUD showError:response.reason];

    }

    

    <#//添加上拉加载#>

    <#self.tableView.mj_footer = [MJRefreshBackNormalFooter footerWithRefreshingTarget:self refreshingAction:@selector(loadMoreData)];#>

    

    if (response.result<#[@"pageInfo"][@"currentPage"]#> >= response.result<#[@"pageInfo"][@"totalPage"]#>) {

        

        <#[self.tableView.mj_header endRefreshing];#>

        

        [self.tableView.mj_footer endRefreshingWithNoMoreData];

        

    }else {

        [self.tableView.mj_<#header#> endRefreshing];

    }

    

} error:^(NSError *error) {

    

}];

 

 

 

定义宏进行懒加载!!!!!!!!!!!!

#define ArrayLazyLoad(x) if (!x) { x = [NSMutableArray new];}return x

 

/**<#系统坐标转换屏幕坐标#>*/

//获取当前绘制上下文
CGContextRef context = UIGraphicsGetCurrentContext();
//设置字形的变换矩阵为不做图形变换 
CGContextSetTextMatrix(<#context#>, CGAffineTransformIdentity);
//平移方法,将画布向上平移一个屏幕高 
CGContextTranslateCTM(<#context#>, <#0#>, <#self.bounds.size.height#>); 
//缩放方法,x轴缩放系数为1,则不变,y轴缩放系数为-1,则相当于以x轴为轴旋转180度
CGContextScaleCTM(<#context#>, <#1.0#>, <#-1.0#>);

 

懒加载!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

/**<#懒加载#>*/

- (<#类名#>)<#变量名#> {

 

    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);

    }

}

 

posted @ 2017-01-11 13:47  t天t天  阅读(267)  评论(0编辑  收藏  举报