与时俱进的IT

UI(十二)cell+按钮+多种cell

2018-07-30  本文已影响0人  社会主义顶梁鹿

self.window.rootViewController = [[UINavigationController alloc]initWithRootViewController:[[ViewController alloc]init]];

//section:组

//row:行

//都是从0开始

//判断cell是否被初始化过 使用identifier 标示符来判断

//判断哪一类cell也是通过identifier来判断

/*tableView的重用机制->滚筒原理

cell.selectionStyle = UITableViewCellSelectionStyleNone;

cell.selectionStyle //cell的选中样式

/*

 自定义选中cell的颜色

 */

//- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

//    //通过tableView 和indexPath 找到对应的cell

//    //cellForRowAtIndexPath:找到IndexPath对应的cell

//    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

//    cell.backgroundColor = [UIColor orangeColor];

//}

//点击cell 找到上一次点击的cell

//- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {

//    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

//    cell.backgroundColor = [UIColor whiteColor];

//}

自定义cell风格

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString*)reuseIdentifier{

 self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];

 if (self) {

   }

 return self;

}

//跳转页面->视图控制器之间的任务

 //view本身不具备跳转视图控制器的功能

 //view 所在的 viewController 具备跳转视图控制器的功能->view 想跳转的时候告诉他所在的视图控制器帮忙跳转

 //可以使用代理实现

//viewController 需要找到是哪个cell +按钮的tag值 才能跳转到相应的视图

自定义属性的相关知识点

/*

 retain:引用计数+1 目的是不让这个对象释放掉->MRC->手动管理neic

 strong:强引用 不会被轻易释放掉 使用完成后对象才被释放->ARC->不能手动管理内存 ->用到UI控件里面、自己创建的类的对象

 copy:拷贝 为了防止原数据影响使用之后的数据 ->copy(必须得遵守拷贝协议)->数组、字典、字符串

 assign:直接赋值 用于基本数据类型也包含基本数据类型演化出来的类型 ->int nsinttager bool float...->只要是数字的都可以用assign

 weak:弱引用 当出现内存警告的时候 会优先释放掉这个对象

 */

/*数字的使用assign

 *数组、字典、字符串使用copy

 *其他使用strong、weak

 */

//没有设置背景图用这个方法

 self.edgesForExtendedLayout = UIRectEdgeNone;

上一篇下一篇

猜你喜欢

热点阅读