开发者

How do you change the width of a UITableView?

I'm new to iPhone development, coming from a web application development background and I'm working on my fi开发者_JAVA技巧rst project. I chose to create a Navigation based project, since after reading it seemed to be the easiest way to get what I'm after. How do you change the width of the UITableView? Eventually, I'd like to have a top bar, UITableView, and bottom bar be 304px wide. I've tried the following in my RootViewController's viewDidLoad method, but I'm doing it wrong:

CGRect tableViewFrame = self.tableView.frame;
tableViewFrame.size.width = 200;
self.tableView.frame = tableViewFrame;

Thanks for any help in advance.


If you want to change the width of the tableViewCell.. go to cellForRowAtIndexPath, and assign it there.

You could also do -

CGFloat tableBorderLeft = 1;
CGFloat tableBorderRight = 1;

CGRect tableRect = self.view.frame;
tableRect.origin.x += tableBorderLeft; // make the table begin a few pixels right from its origin
tableRect.size.width -= tableBorderLeft + tableBorderRight; // reduce the width of the table
tableView.frame = tableRect;

For changing the size of header

-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
return 150.0;  //Give a value
}

For changing size of footer

-(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
{
return 150.0;//Give a value
}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜