I have a UIPopoverController which loads w开发者_StackOverflow中文版ith a custom controller which is a subclass of UITableViewController. It serves to present a number of suggestions, under a search bar.
When my popover opens the UITableView inside it show as many rows as possible; the first ones show the choices I set up, the last ones are blank. What I am trying to achieve is showing just N number of rows (corresponding to the choices I am offering), and getting rid of the empty cells at the bottom.
I have been trying a number of different techniques: I have been assigning a custom frame in viewWillAppear:animated and in viewDidAppear:animated; I have been fiddling with the autoresizing properties in IB; I can't use init or viewDidLoad because the table content is dynamic.
I am quite sure that I'm being dumb here, there msut be an easy way to accomplish this. Any suggestion?
Cheers, Davideyou can set the number of rows that will appear in the table by using the UITableViewDataSourceProtocol method:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
More on this is covered in the documentation found here:
http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UITableViewDataSource_Protocol/Reference/Reference.html
Basically, you simply return the following inside the method:
numberOfRowsInSection {
if (section == someSection) { if (row == someRow) { return thisManyRows; } }
Hope this helps :)
精彩评论