示例:

//
// 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 中代码书写规范的更多相关文章

  1. WEB标准:标准定义、好处、名词解释、常用术语、命名习惯、浏览器兼容、代码书写规范

    1. WEB标准是什么? “WEB标准”是一系列标准的总称.一般的误区经常把WEB标准说成DIV+CSS.准确的说法应该是:采用W3C推荐的WEB标准中的XHTML1.1结合CSS2.0 样式表制作页 ...

  2. C#中的代码书写规范以及命名规范

    C#代码书写规则: 1. 尽量使用接口,然后使用类实现接口,以提高程序的灵活性. 2.一行不要超过80个字符 3.尽量不要手动更改计算机生成的代码 4.关键的语句写注释 5.建议局部变量在最接近使用它 ...

  3. (转)Java代码书写规范

    0. 安装阿里代码规范的eclipse插件 https://www.cnblogs.com/caer/p/7753522.html 1.基本原则 强制性原则:     1.字符串的拼加操作,必须使用S ...

  4. Unity项目代码书写规范

    以Google的代码规范为主,稍加改动 https://google.github.io/styleguide/csharp-style.html 书写规范 基础写法 Pascal和驼峰混用,参数用驼 ...

  5. C++代码书写规范——给新手程序员的一些建议

    代码就是程序员的面子,无论是在工作中在电脑上写程序代码还是在面试时在纸上写演示代码我们都希望写出整洁,优雅的代码.特别在工作中当我们碰到需要维护别人的代码,或者是多人参与一个项目大家一起写代码的时候, ...

  6. 【转】JavaScript常用代码书写规范

    javascript 代码规范 代码规范我们应该遵循古老的原则:“能做并不意味着应该做”. 全局命名空间污染 总是将代码包裹在一个立即的函数表达式里面,形成一个独立的模块. 不推荐 1 2 3 var ...

  7. JavaScript常用代码书写规范

    javascript 代码规范 代码规范我们应该遵循古老的原则:“能做并不意味着应该做”. 全局命名空间污染 总是将代码包裹在一个立即的函数表达式里面,形成一个独立的模块. 不推荐 , y = ; c ...

  8. Python代码书写规范

    Python 编码规范 一 代码编排1 缩进.4个空格的缩进(编辑器都可以完成此功能),不要使用Tap,更不能混合使用Tap和空格.2 每行最大长度79,换行可以使用反斜杠,最好使用圆括号.换行点要在 ...

  9. c: c代码书写规范

    排版: 较长的语句或函数过程参数(>80字符)要分成多行书写, 长表达式要在低优先级操作符处划分新行,操作符放在新行之首, 划分出的新行要进行适当的缩进,使排版整齐,语句可读 参考: 1. 运算 ...

随机推荐

  1. 【转载】Windows环境下JNI的实现实例

    转自:http://blog.csdn.net/jjunjoe/article/details/6987183 一.关于JNI: JNI(Java Native Interface):Java本地调用 ...

  2. html中的路径详解

    路径指文件存放的位置,在网页中利用路径可以引用文件,插入图像.视频等.表示路径的方法有两种:相对路径,绝对路径.以下讨论均是在HTML环境下进行. 相对路径 相对路径是指目标相对于当前文件的路径,网页 ...

  3. google插件跨域含用户请求WebApi解决的方案

    问题描述: google插件跨域请求WebApi相关解决方案 1.ajax解决含登录用户信息 $.ajax({ url: url, type: "POST", timeout: 6 ...

  4. HDU 1326 Box of Bricks(思维)

    Little Bob likes playing with his box of bricks. He puts the bricks one upon another and builds stac ...

  5. [消灭虫子] Qt 套接字发不出去东西

    最近状态不是太好,导致出现bug之后心烦意乱的 遇到这样的事情,就是在 这样的函数执行之后服务端收不到任何消息,但是在调试台显示已经发送了正常的字节数. 表示大概已经发出去了,但是我确定服务端没有问题 ...

  6. radar图生成用户guideline

    1.最后生成的效果是这样的: 2.第一个对话框如下(包含了样图),用于输入维度个数[最小为4,最大不限]: 3.第二个对话框如下,根据维度个数生成了信息录入表[每个维度3个信息,每3个一次重复,不清楚 ...

  7. Python中的参数解包:`*`表达式和 `**`表达式

    目录 1.参数解包:方法调用中的*表达式和**表达式 2.参数解包:方法定义中的*表达式和**表达式 3.在元组,列表,集合和字典中解包 4.Extended Unpacking:赋值表达式左边的*表 ...

  8. 如何创建Maven项目和Spring IOC例子

    把如何创建Maven项目和创建Spring IOC的例子分享给大家,希望能对大家有帮助! 我的博客地址:https://www.cnblogs.com/themysteryofhackers/p/12 ...

  9. mysql客户端的导出数据库表和数据库数据等相关操作

    1.navicat for mysql 11.0.10客户端 导出数据库里所有表中的所有数据,方法如下,选中表,在横向导航栏里面找到“导出向导”,选中sql,点击下一步,点击全选,并且选中“应用相同目 ...

  10. web前端技能考核(阿里巴巴)