2011-10-31 32 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]; 

它试图滚动到不存在的细胞线。