在下面的代碼中,當我點擊一個按鈕時,我推送一個新的UITableView。 TableView有25行。我可以看到第9排和第10排被切斷。我無法向下滾動查看其餘的行。我如何使TableView可滾動?謝謝。如何製作我的UITableView滾動?
- (IBAction)showListPicker:(id)sender {
ListPicker *lp = [[ListPicker alloc] initWithStyle:UITableViewStyleGrouped];
[self setTitle:@"Home"];
[[self navigationController] pushViewController:lp animated:YES];
[lp release];
}
以下是ListPicker
#import <Foundation/Foundation.h>
@interface ListPicker : UITableViewController
{}
@end
以下聲明爲ListPIcker
實施#import "ListPicker.h"
#import "GameStore.h"
#import "List.h"
#import "HomeViewController.h"
@implementation ListPicker
- (id)init
{
return [super initWithStyle:UITableViewStyleGrouped];
}
-(id)initWithStyle:(UITableViewStyle)style{
return [self init];
}
-(void)dealloc{
[super dealloc];
}
-(void)viewDidLoad{
[self setTitle:@"Select List"];
[[self navigationController] setNavigationBarHidden:NO];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return [[[GameStore defaultStore] allLists] count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"UITableViewCell"];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:@"UITableViewCell"] autorelease];
}
NSArray *allList = [[GameStore defaultStore] allLists];
List *mylist = [allList objectAtIndex:[indexPath row]];
NSString *listTitle = [mylist label];
[[cell textLabel] setText:listTitle];
[cell setAccessoryType:UITableViewCellAccessoryNone];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
List *list = [[[GameStore defaultStore] allLists] objectAtIndex:[indexPath row]];
[[GameStore defaultStore] setSelectedList:list];
HomeViewController *hv = [[HomeViewController alloc] init];
[[self navigationController] popViewControllerAnimated:YES];
}
@end
不知道相關的問題,但在您的實現initWithStyle的':'你可能想要做'返回[超級initWithStyle:風格]'而不是'返回[自我的init];' – filipe
做它彈跳嗎?或者表格是完全固定的? – TommyG
@TommyG它的完全固定 – atbebtg