2011-10-31 95 views
0

我使用故事板與iPad應用程序的分割視圖控制器。並將其初始設置爲分割視圖控制器。我通過一個數組填充主視圖控制器。 'feature'是NSObject類,我聲明方法:UISplitViewController與故事板

- (feature *)initWithName:(NSString *)name iconName:(NSString *)iconName featuresofiphone:(iphoneFeatures)featuresofiphone;
,並在.m類中定義NSString類型的名稱,圖標名稱,featuresofiPhone的特性。 這是我在didFinishLaunchingWithOptions代碼:在主視圖控制器
 exception 'NSRangeException', reason: '-[UITableView scrollToRowAtIndexPath:atScrollPosition:animated:]: row (0) beyond bounds (0) for section (0).'
在:

NSMutableArray *monsters = [NSMutableArray array]; 
[monsters addObject:[[[feature alloc] initWithName:@"iphone3g" 
iconName:@"iphone3g.jpg" featuresofiphone:iphone3gf] autorelease]]; 

[monsters addObject:[[[feature alloc] initWithName:@"iphone3gs" 
iconName:@"iphone3gs.jpg" featuresofiphone:iphone3gsf] autorelease]]; 

[monsters addObject:[[[feature alloc] initWithName:@"iphone4g" iconName:@"iphone4g.jpg" 
featuresofiphone:iphone4gf] autorelease]]; 

MasterViewController *masterDetailViewController = [[MasterViewController alloc]init]; 
masterDetailViewController.iphones = iphonesarray; 

UISplitViewController *splitViewController = (UISplitViewController *)self.window.rootViewController; 
UINavigationController *navigationController = [splitViewController.viewControllers lastObject]; 
splitViewController.delegate = (id)navigationController.topViewController; 
return YES; 

但其給予異常

-(void)viewDidLoad 
{ 
    [super viewDidLoad]; 
// Do any additional setup after loading the view, typically from a nib. 
self.detailViewController = (DetailViewController *) 
[[self.splitViewController.viewControllers lastObject] topViewController]; 
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] 
animated:NO scrollPosition:UITableViewScrollPositionMiddle]; 
} 

和控制還沒有達到到的cellForRowAtIndexPath - 方法。幫幫我!!

回答

0

你沒有足夠的細胞,只是發表評論

[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle]; 

它試圖滾動到不存在的細胞線。