UITableView Cell
2015-08-03 22:51
453 查看
只有Plain格式的tableView才有页眉页脚.而且plain样式的页眉页脚都是悬浮在内容上面的.
identify: 区分.
resume:继续.
懒加载:调用getter方法,所以只针对属性有用.
framework Controls 框架控件 即 系统控件.
UItableViewCellStyleValue1:表格上有imageView (可有可无)和textLabel 还有detailLabel
UITableViewCellStyleSubtitle 组成同value1,只不过textLabel在上面,detailLabel在下面.
可以把可变数组强转成不可变数组,但是不能把不可变强转成可变数组,如果必须这样实施,想到使用mutablecopy 这个方法.
//取出所有的键进行升序排序
NSMutableArray *keyAray = [self.dataDic.allKeysmutableCopy];
[keyAraysortedArrayUsingSelector:@selector(compare:)];
//取出对应分区的键
NSString *key = keyAray[section];
//取出对应分区的value
NSMutableArray *students =self.dataDic[key];
return students.count ;
===
NSMutableArray *keyArray = [self.studentDic.allKeysmutableCopy];
[keyArraysortUsingSelector:@selector(compare:)];
NSString *key = [keyArrayobjectAtIndex:section];
return [[self.studentDicobjectForKey:key]count];
UITableViewDataSource 数据源协议 ; UITableViewDelegate 操作协议
懒加载的本质是调用属性的getter方法.因此懒加载中我们只能使用setter方法创建对象,不能使用getter方法,因为本身就是getter方法,如果再用的话会陷入无限循环.Error:
// self.dataDic setObject:<#(id)#> forKey:<#(id<NSCopying>)#>
懒加载中创建对象必须使用setter方法(self.dataDic)赋值,如果不能使用setter方法,比如(_dataDic)赋值会因为野指针问题造成程序崩溃[IOS内部,每一个方法内部附近都有一个autoreleasepool,所以这里如果不调用setter方法,则dataDic的便利构造器会alloc和autorelease.
- (NSMutableDictionary *)dataDic
{
if (_dataDic ==nil)
{
//懒加载中创建对象必须使用setter方法(self.dataDic)赋值.如果不使用setter方法赋值就会因为野指针问题造成程序奔溃.(IOS内部,每一个方法附近都有一个autoreleasepool,所以这里如果不调用setter方法,则dataDic的便利构造器会alloc和autorelease
)
self.dataDic = [NSMutableDictionarydictionaryWithCapacity:0];
// self.dataDic setObject:<#(id)#> forKey:<#(id<NSCopying>)#>error
}
return [[_dataDicretain]autorelease];//getter方法的标准写法
}
=================分割线左对齐===================
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
然后在willDisplayCell方法中加入如下代码:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
identify: 区分.
resume:继续.
懒加载:调用getter方法,所以只针对属性有用.
framework Controls 框架控件 即 系统控件.
UItableViewCellStyleValue1:表格上有imageView (可有可无)和textLabel 还有detailLabel
UITableViewCellStyleSubtitle 组成同value1,只不过textLabel在上面,detailLabel在下面.
可以把可变数组强转成不可变数组,但是不能把不可变强转成可变数组,如果必须这样实施,想到使用mutablecopy 这个方法.
//取出所有的键进行升序排序
NSMutableArray *keyAray = [self.dataDic.allKeysmutableCopy];
[keyAraysortedArrayUsingSelector:@selector(compare:)];
//取出对应分区的键
NSString *key = keyAray[section];
//取出对应分区的value
NSMutableArray *students =self.dataDic[key];
return students.count ;
===
NSMutableArray *keyArray = [self.studentDic.allKeysmutableCopy];
[keyArraysortUsingSelector:@selector(compare:)];
NSString *key = [keyArrayobjectAtIndex:section];
return [[self.studentDicobjectForKey:key]count];
UITableViewDataSource 数据源协议 ; UITableViewDelegate 操作协议
懒加载的本质是调用属性的getter方法.因此懒加载中我们只能使用setter方法创建对象,不能使用getter方法,因为本身就是getter方法,如果再用的话会陷入无限循环.Error:
// self.dataDic setObject:<#(id)#> forKey:<#(id<NSCopying>)#>
懒加载中创建对象必须使用setter方法(self.dataDic)赋值,如果不能使用setter方法,比如(_dataDic)赋值会因为野指针问题造成程序崩溃[IOS内部,每一个方法内部附近都有一个autoreleasepool,所以这里如果不调用setter方法,则dataDic的便利构造器会alloc和autorelease.
- (NSMutableDictionary *)dataDic
{
if (_dataDic ==nil)
{
//懒加载中创建对象必须使用setter方法(self.dataDic)赋值.如果不使用setter方法赋值就会因为野指针问题造成程序奔溃.(IOS内部,每一个方法附近都有一个autoreleasepool,所以这里如果不调用setter方法,则dataDic的便利构造器会alloc和autorelease
)
self.dataDic = [NSMutableDictionarydictionaryWithCapacity:0];
// self.dataDic setObject:<#(id)#> forKey:<#(id<NSCopying>)#>error
}
return [[_dataDicretain]autorelease];//getter方法的标准写法
}
=================分割线左对齐===================
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsZero];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsZero];
}
然后在willDisplayCell方法中加入如下代码:
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
相关文章推荐
- UE4信息交互-蓝图类中的信息交互
- UI 03 关于UITextField键盘遮挡问题
- FZU 1752 Quickmod Quickmulti
- Android UI: LinearLayout中layout_weight 属性的使用规则
- Xcode6以后segue取消原push与modal(deprecated)
- UI 03 UIButton 和 UITextField
- UITextField总结
- Unknown Class XX in Interface Builder File
- UIRectEdge
- UICntrol
- [leetcode-60]Permutation Sequence(C)
- hdu 4893 Wow! Such Sequence! (线段树 区间更新+单点更新)
- POJ2785 4 Values whose Sum is 0
- UISwitch
- [2015hdu多校联赛补题]hdu5297 Y sequence
- hdoj 1005 Number Sequence
- zoj2587 Unique Attack 判断最小割是否唯一
- Havok_2014-1-0_Pc_Xs_User_Guide(1.1.1-简介)
- 怎么解决UIScrollView把uitableviewcell的点击事件屏蔽了
- UISwitch