开发者

How to Edit custom UITableViewCell's Frame size?

I am using custom UITableViewCell class to make table view cell. I am changing row height dynamically:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(开发者_如何学运维NSIndexPath *)indexPath {
    return 60;
}

Its working for row height perfectly.

But this only changing the row height, not the Cell's Frame height. The Cell frame height is still 44 (default). So how can I make it effective for both row height as well as cell frame?

Thanks in advance..


while creating the cell in cellforrow

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
 {

  UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];

 if (cell == nil) 
 {
     cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,90,90) reuseIdentifier:@"MyIdentifier"] autorelease];
 }
return cell;

}

note this line

     cell = [[[UITableViewCell alloc] initWithFrame:CGRectMake(0,0,90,90) reuseIdentifier:@"MyIdentifier"] autorelease];

CGRectMake(0,0,90,90) change this as u needed


Just write one line in cellForRowIndexAtPath: data source method.

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
   cell.frame = CGRectMake(0,0,320,60);

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜