Relative Height of UITableview
In RootViewController
am using a UITableView for displaying the content of data. In the didSelectRowAtIndexPath
method, I am calling another view controller (DetailViewController
) to display detailed data. For displaying this detailed data I am using a UITableview
in the DetailVi开发者_如何学GoewController
also. This table contains one section and only one row.
Now the problem is that I have to adjust the table's height dynamically when I move from RootViewController
to DetailViewController
. How can I make the height of the UITableView
dynamic between the two classes?
Any help would be Appreciated!
You can implement the UITableViewDelegate method something like:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [TextToDisplay sizeWithFont:/*DESIRED_FONT*/ constrainedToSize:/*YOUR DESIRED_SIZE*/ lineBreakMode:/*DESIRED_LINEBREAKMODE*/].height;
}
to get variable heights.
It sounds like your trying to reuse a UITableView
between two different UIViewControllers
. I think your better off having the RootViewController
have it's own UITableView
which is set to a dynamic height and width using the UIView autoresizingMask
property. Then when you select a row and push on the DetailViewController
in a UINavigationController
stack it would have it'd own UITableView
to display the detail information your trying to show.
This interaction technique is used throughout other iPhone applications like Mail. If I misunderstood your question please let me know.
精彩评论