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. 运算 ...
随机推荐
- 【c++】零基础的自修课 01-开发工具的安装(code::blocks)
1/开发工具的下载地址: ·(选用 visual studio开发工具,有区分mac和windows版本)https://visualstudio.microsoft.com/zh-hans/down ...
- WPF学习笔记一之布局
1.Canvas 布局控件Canvas主要用来画图,注意Canvas.Left/Right/Top/Bottom <Canvas Margin="10,10,10,10" B ...
- codeforces 711 D.Directed Roads(tarjan 强连通分量 )
题目链接:http://codeforces.com/contest/711/problem/D 题目大意:Udayland有一些小镇,小镇和小镇之间连接着路,在某些区域内,如果从小镇Ai开始,找到一 ...
- 剑指offer 面试题35.复杂链表的复制
时间O(N),空间O(N) /* struct RandomListNode { int label; struct RandomListNode *next, *random; RandomList ...
- php商城数据库的设计 之无限分类
商品分类,使用无限分类 即: -------如何创建数据表 pid---父级分类id,如果是顶级分类则为0 path---1,用户分类的排序 . 排序示例: 实现逻辑:获取type表的所有分类,ord ...
- Vue - 动态组件 & 异步组件
动态组件 <div id="app"> <components :is="com[2]"></components> < ...
- C# 泛型说明
详细说明转 https://www.cnblogs.com/dotnet261010/p/9034594.html 最近项目用到了多个参数的泛型方法,这里说明下泛型的组成: /// <summa ...
- opencv:图像轮廓计算
#include <opencv2/opencv.hpp> #include <iostream> using namespace cv; using namespace st ...
- Chrome下ifame父窗口调用子窗口的问题
function changeMenu(menu_id){ frames[0].changeMenu(menu_id); } https://blog.csdn.net/caohaicheng/art ...
- Lc626_换座位
626. 换座位 SQL架构 小美是一所中学的信息科技老师,她有一张 seat 座位表,平时用来储存学生名字和与他们相对应的座位 id. 其中纵列的 id 是连续递增的 小美想改变相邻俩学生的座位. ...