《iOS5 programming cookbook》学习笔记3

第三章小感:

Messages sent to the delegate object of a table view carry a parameter that tells thedelegate object which table view has fired that message in its delegate. This is veryimportant to make note of because you might, under certain circumstances, requiremore than one table view to be placed on one object (usually a view). Because of this,it is highly recommended that you make your decisions based on which table view hasactually sent that specific message to your delegate object, like so:

- (CGFloat) tableView:(UITableView *)tableViewheightForRowAtIndexPath:(NSIndexPath *)indexPath{

CGFloat result = 20.0f;

if ([tableView isEqual:self.myTableView]){

result = 40.0f;}

return result;} 

这段的意思应该是: f ([tableView isEqual:self.myTableView]) 加上这句话吧,还真没有这个习惯。嗯,以后加上。


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* result = nil;
static NSString *MyCellIdentifier = @"SimpleCells";
result = [tableView dequeueReusableCellWithIdentifier:MyCellIdentifier];
if (result == nil){
result = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:MyCellIdentifier];
}
result.textLabel.text = [NSString stringWithFormat:@"Section %ld, Cell %ld",
(long)indexPath.section, (long)indexPath.row];
result.indentationLevel = indexPath.row; result.indentationWidth = 10.0f;
return result; }


看了这个觉得纳闷,我记得之前是用一个委托来做的啊,翻阅了一下,委托,发现都是叫indentationLevel,哦,就当时两个方法都可以实现这个功能吧。


嗯,还有一点是,After this property is set, Cocoa Touch will ignore the value of the accessoryType property and will use the view assigned to the accessory View property as the accessory assigned to the cell.。
也就是说,Cocoa Touch 会忽略accessoryType这个熟悉,如果用了accessory View 这个熟悉。


the table viewwill notice this move and will then shift Section B to the previous position of SectionA and will move Section B to the previous position of Section B.  

这里有笔误。哈哈,应该把c放到先前b的地方


看完第三章了,啊哈哈。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值