iOS ViewController 中代码书写规范
示例:
//
// CommonViewController.m
// ZTBCamera
//
// Created by ZachRobin on 2017/8/3.
// Copyright © 2017年 Dreams of Ideal World Co.,Ltd. All rights reserved.
// static const CGFloat customValue = ; //定义静态变量 #define kScreenWidth [[UIScreen mainScreen] bounds].size.width //定义 #import "CommonViewController.h" #import "MagnumOpusCell.h" //引入头文件
#import "MagnumOpusDetailViewController.h" @interface CommonViewController () <UITableViewDelegate, UITableViewDataSource, MagnumOpusCellDelegate>
{
NSString *varableStr;//定义变量
} @property (nonatomic, strong) UITableView *contentTableView; @end @implementation CommonViewController #pragma mark - ViewController Life Cycle
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view. UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
button.frame = CGRectMake(, , , );
[button setTitle:@"按钮" forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor redColor]];
[button addTarget:self action:@selector(buttonDidClick:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:button];
} - (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
} - (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
} - (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
} #pragma mark - System Delegate --
#pragma mark - UITableViewDelegate / UITableViewDataSource
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return ;//_contentArray.count
} - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
MagnumOpusCell *cell=[self.contentTableView dequeueReusableCellWithIdentifier:@"IDMagnumOpusCell"];
if (!cell) {
cell = [[MagnumOpusCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"IDMagnumOpusCell"];
}
[cell buildCellWithItem:nil];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
} - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
MagnumOpusCell *cell = (MagnumOpusCell *)[self tableView:self.contentTableView cellForRowAtIndexPath:indexPath];
return [cell getCellHeight];
} - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"当前选中了 %ld", indexPath.row);
MagnumOpusDetailViewController *VC = [[MagnumOpusDetailViewController alloc] init];
[self.navigationController pushViewController:VC animated:YES];
} #pragma mark - Customer Delegate
- (void)removeCurrentCellData:(id)index
{ } #pragma mark - Event Response
- (void)buttonDidClick:(id)sender
{
[self requestData];
} #pragma mark - Private Method
- (void)requestData
{ } #pragma mark - Getters / Setters
- (UITableView *)contentTableView
{
if (!_contentTableView) {
_contentTableView = [[UITableView alloc] initWithFrame:CGRectMake(, , self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
_contentTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_contentTableView.showsVerticalScrollIndicator = NO;
_contentTableView.delegate = self;
_contentTableView.dataSource = self;
UINib *nib = [UINib nibWithNibName:@"MagnumOpusCell" bundle:[NSBundle mainBundle]];
_contentTableView.backgroundColor = [UIColor clearColor];
_contentTableView.showsVerticalScrollIndicator = NO;
[_contentTableView registerNib:nib forCellReuseIdentifier:@"IDMagnumOpusCell"];
}
return _contentTableView;
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} /*
#pragma mark - Navigation // In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/ @end
附件:示例代码。
iOS ViewController 中代码书写规范的更多相关文章
- WEB标准:标准定义、好处、名词解释、常用术语、命名习惯、浏览器兼容、代码书写规范
1. WEB标准是什么? “WEB标准”是一系列标准的总称.一般的误区经常把WEB标准说成DIV+CSS.准确的说法应该是:采用W3C推荐的WEB标准中的XHTML1.1结合CSS2.0 样式表制作页 ...
- C#中的代码书写规范以及命名规范
C#代码书写规则: 1. 尽量使用接口,然后使用类实现接口,以提高程序的灵活性. 2.一行不要超过80个字符 3.尽量不要手动更改计算机生成的代码 4.关键的语句写注释 5.建议局部变量在最接近使用它 ...
- (转)Java代码书写规范
0. 安装阿里代码规范的eclipse插件 https://www.cnblogs.com/caer/p/7753522.html 1.基本原则 强制性原则: 1.字符串的拼加操作,必须使用S ...
- Unity项目代码书写规范
以Google的代码规范为主,稍加改动 https://google.github.io/styleguide/csharp-style.html 书写规范 基础写法 Pascal和驼峰混用,参数用驼 ...
- C++代码书写规范——给新手程序员的一些建议
代码就是程序员的面子,无论是在工作中在电脑上写程序代码还是在面试时在纸上写演示代码我们都希望写出整洁,优雅的代码.特别在工作中当我们碰到需要维护别人的代码,或者是多人参与一个项目大家一起写代码的时候, ...
- 【转】JavaScript常用代码书写规范
javascript 代码规范 代码规范我们应该遵循古老的原则:“能做并不意味着应该做”. 全局命名空间污染 总是将代码包裹在一个立即的函数表达式里面,形成一个独立的模块. 不推荐 1 2 3 var ...
- JavaScript常用代码书写规范
javascript 代码规范 代码规范我们应该遵循古老的原则:“能做并不意味着应该做”. 全局命名空间污染 总是将代码包裹在一个立即的函数表达式里面,形成一个独立的模块. 不推荐 , y = ; c ...
- Python代码书写规范
Python 编码规范 一 代码编排1 缩进.4个空格的缩进(编辑器都可以完成此功能),不要使用Tap,更不能混合使用Tap和空格.2 每行最大长度79,换行可以使用反斜杠,最好使用圆括号.换行点要在 ...
- c: c代码书写规范
排版: 较长的语句或函数过程参数(>80字符)要分成多行书写, 长表达式要在低优先级操作符处划分新行,操作符放在新行之首, 划分出的新行要进行适当的缩进,使排版整齐,语句可读 参考: 1. 运算 ...
随机推荐
- python-excel读取-pyodbc
https://github.com/mkleehammer/pyodbc/wiki/Cursor 利用pyodbc读取数据库,流程基本一样,就是配置connect对象时有所不同,下面是excel的: ...
- makecert 产出证书
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Bin>makecert -r -n // -e // -sv mymuse.pvk my ...
- vue中父组件向子组件传值问题
问题:当父组件传值给子组件echarts时,发现子组件获取的props为空,刚开始以为是钩子函数放错了地方,后来发现从mounted和created都不行.当在父组件data定义传递的数据的时候子组件 ...
- Vue - 解决路由过渡动画抖动问题
前言 Vue-Router 作为 Vue 的核心模块,它为我们提供了基于组件的路由配置.路由参数等功能,让单页面应用变得更易于管理.良好的路由管理尤为重要,比如路由拦截.路由懒加载.路由权限等都在开发 ...
- POJ 3991 括号匹配问题(贪心)
I’m out of stories. For years I’ve been writing stories, some rather silly, just to make simple prob ...
- 第十八篇 Linux环境下常用软件安装和使用指南
提醒:如果之后要安装virtualenvwrapper的话,可以直接跳到安装virtualenvwrapper的方法,而不需要先安装好virtualenv 安装virtualenv和生 ...
- PHP把空格、换行符、中文逗号等替换成英文逗号的正则表达式
$test=$_POST["test"]; $test= preg_replace("/(\n)|(\s)|(\t)|(\')|(')|(,)/" ,',' , ...
- linux shell let, expr 命令详解
linux命令之let.exprshell程序中的操作默认都是字符串操作,在运行数学运算符的时候可能得到意想不到的答案: var=1var=$var+1echo $var 将输出 1+1从这个例子中可 ...
- 【Python】爬虫原理
前言 简单来说互联网是由一个个站点和网络设备组成的大网,我们通过浏览器访问站点,站点把HTML.JS.CSS代码返回给浏览器,这些代码经过浏览器解析.渲染,将丰富多彩的网页呈现我们眼前: 一.爬虫是什 ...
- http://localhost:8080/sockjs-node/info?t=1556418283950 net:: ERR_CONNECTION_REFUSED(亲测有效~!)
如果你的项目没有用到sockjs,vuecli3 运行npm run serve 之后network里面一直调用一个接口:http://localhost:8080/sockjs-node/info? ...