Iphone 拆分视图应用程序,如何调用位于根视图中的函数?
我正在制作一个分割视图应用程序。在RootController中,有一个函数用于指向tableview的下一个单元格:Iphone 拆分视图应用程序,如何调用位于根视图中的函数?,iphone,objective-c,uitableview,uisplitviewcontroller,Iphone,Objective C,Uitableview,Uisplitviewcontroller,我正在制作一个分割视图应用程序。在RootController中,有一个函数用于指向tableview的下一个单元格: -(void)goToNextCell { NSIndexPath *nextCell = [NSIndexPath indexPathForRow:currentSelection.row+1 inSection:currentSelection.section]; [self.tableView selectRowAtIndexPath:nextCell
-(void)goToNextCell
{
NSIndexPath *nextCell = [NSIndexPath indexPathForRow:currentSelection.row+1 inSection:currentSelection.section];
[self.tableView selectRowAtIndexPath:nextCell animated:YES scrollPosition: UITableViewScrollPositionTop];
NSLog(@"Went to next Cell!");
}
在详细视图中,在“下一个单元格”旁边有一个按钮:
-(IBAction)goToNextTextClicked:(id)sender
{
//Should call this function ^^^^ HOW?(((
}
我通常通过在我的detail view controller类标头中定义委托协议来完成这类工作,如下所示:
@protocol DetailViewControllerDelegate
- (void)didClickGoToNext;
@end
@interface DetailViewController {
id<DetailViewControllerDelegate> delegate;
}
@property (nonatomic, assign) id<DetailViewControllerDelegate> delegate;
@end
最后,我将让根视图控制器实现DetailViewControllerDelegate协议,并将其自身设置为委托。当按下详细视图控制器的按钮时,根视图控制器现在将收到通知,它可以做出相应的反应。我通常通过在我的详细视图控制器类标题中定义委托协议来完成这类工作,如下所示:
@protocol DetailViewControllerDelegate
- (void)didClickGoToNext;
@end
@interface DetailViewController {
id<DetailViewControllerDelegate> delegate;
}
@property (nonatomic, assign) id<DetailViewControllerDelegate> delegate;
@end
最后,我将让根视图控制器实现DetailViewControllerDelegate协议,并将其自身设置为委托。当按下详细视图控制器的按钮时,根视图控制器现在将收到通知,并且它可以做出相应的反应