开发者

can UITableViewController be customized to very compact/small fonts?

I want to develop a view that is quite compact in terms of font size and row heights.

Is it possible to customize UITableViewController so that the font size / row height you used is whatever? In fact the more general question is UITableViewController easy to customize such that you can put what ever you want in it and just use it for the framework for showing your customized cells?

Interested in knowing if there are any gottcha's here, and if there were some what would be the next option? Would it be go straight to having to "draw" your own interface using drawing type commands?

(trying to determine where to dig-in in terms of readin开发者_JAVA技巧g up)

thanks


If all of your cells are homogenous, you can adjust the rowHeight property of UITableViewController's instance of UITableView.

self.tableView.rowHeight = 22.0

For cells of varying heights, you will have to implement the UITableViewDelegate method, - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath.

In this method, you will determine how much text needs to be displayed given the indexPath and calculate and return a height value for that row.

Having said all that, Apple's Human Interface Guidelines recommend that UITableViewCell heights should be 44 points at least, given the thickness of human fingers.


depending on the UITableViewCellStyle you are working with you have a textLabel and detailTextLabel elements to work with and you can set font/size/color on them.

cell.detailTextLabel.font = [UIFont boldSystemFontOfSize:18]; for an example.

i hear that putting these modifications in

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath

is the proper thing to do.


Here's the way to set the row height. Apparently doing this way is better than setting it within the willDisplayCell method due to overheads

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CGFloat result;
    result = 20;
    return result;
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜