Xcode常用代码块整理

来源:互联网 发布:淘宝卖家能给差评吗 编辑:程序博客网 时间:2024/06/14 08:57

一、屏幕尺寸
//快捷键 Screen Size

/** 屏幕尺寸参数 */#define SCREEN_WIDTH        ([UIScreen mainScreen].bounds.size.width)#define SCREEN_HEIGHT       ([UIScreen mainScreen].bounds.size.height)

二、初始化函数
//快捷键 initBase

#pragma mark - **************** 初始化操作- (void)initBaseData {}- (void)initBaseView {}

三、属性
strong、copy,assign
//快捷键:strongg 、 copyy 、assignn

//@property(nonatomic,strong)<#type#> *//@property(nonatomic,copy)<#type#> *//@property(nonatomic,assign)<#type#>

四、tableview创建
//快捷键 tableViewDelegate

#pragma mark lazy loading...-(UITableView *)tableView {    if (!_tableView) {        _tableView = [[UITableView alloc]initWithFrame:self.view.bounds style:UITableViewStylePlain];        _tableView.delegate = self;        _tableView.dataSource = self;    }    return _tableView;}#pragma tableView--delegate#pragma tableView-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {    return <#expression#>}-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {    return <#expression#>}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {    static NSString *identify = @"cellIdentify";    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identify];    if (!cell) {        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:identify];    }    cell.textLabel.text = self.arrayTitle[indexPath.row];    return cell;}-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {}

五、webview创建
//快捷键 webView delegate

#pragma mark--webView-(UIWebView *)webView {    if (!_webView) {        _webView = [[UIWebView alloc]initWithFrame:CGRectMake(0, 50, SCREEN_WIDTH, SCREEN_HEIGHT)];        _webView.scalesPageToFit = YES;        _webView.delegate = self;        _webView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;    }    return _webView;}#pragma mark--webview的delegate/** start */-(void)webViewDidStartLoad:(UIWebView *)webView {}/** start loading */-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {    return YES;}/** finish */-(void)webViewDidFinishLoad:(UIWebView *)webView {}/** error */-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {}

六、button创建
//快捷键 button create

#pragma mark--button create    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];    btn.frame = CGRectMake(100, 100, 100, 50);    btn.backgroundColor = [UIColor orangeColor];    [btn addTarget:self action:@selector(clicked:) forControlEvents:UIControlEventTouchUpInside];    [self.view addSubview:btn];

七、注释

/** <#注释#> */                              快捷键 explain property// --<#说明#>                                快捷键 explain single#pragma mark - **************** <#输入注释#>  快捷键 explain mark

快捷键说明

八、待处理事项
//快捷键 waring

#warning TODO <#message#>

目前先整理这些,后续遇到再补加。

1 0
原创粉丝点击