开发者

One table view cell/row bigger than others?

开发者 https://www.devze.com 2022-12-29 07:24 出处:网络
I know it is possible to set the height of all rows in a UITable but is it possible to set one row to be bigger than the others.

I know it is possible to set the height of all rows in a UITable but is it possible to set one row to be bigger than the others. For example when the user touches on the cell with 2 fingers 开发者_开发百科I want the cell to expand and show a description. But only that cell. Is that possible without overlapping the cells below it?


Use the UITableViewDelegate method heightForRowAtIndexPath

Say that your data model stored objects that have a height property:

 - ( void ) changeHeightForRowAtIndexPath: ( NSIndexPath *) indexPath ( NSInteger ) height {
    [ myData objectAtIndex: indexPath.row ].height = height;
    [ myTableView reloadRowsAtIndexPaths: [ NSArray arrayWithObject: indexPath ] withRowAnimation: UITableViewRowAnimationNone ];
 }


Override this method - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath.

http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UITableViewDelegate_Protocol/Reference/Reference.html#//apple_ref/occ/intfm/UITableViewDelegate/tableView:heightForRowAtIndexPath:

0

精彩评论

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