您的位置:首页 > 产品设计 > UI/UE

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];

}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: