我有一个带有UITableView
的应用程序(在PatientViewController
中),并且在不同单元格上的每个单击都应向ArticleViewController
发送不同的值。我用此代码在ViewControllers
之间进行了所有过渡:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil];
NewsViewController *mv = (NewsViewController*)[mainStoryboard instantiateViewControllerWithIdentifier:@"news"];
[self presentViewController:mv animated:YES completion:NULL];
我不想使用NavigationController
,也不想使用故事板来创建SEGUE。那么,我只能在不使用故事板的情况下仅使用编写代码来完成操作呢?谢谢。
您可以创建一个使用以下内容的UistoryBoardsegue:
UIStoryboardSegue :: initWithIdentifier:source:destination:
然后,从源UIViewController
中可以调用以下内容:
performSegueWithIdentifier:sender:
有关详细信息,请参阅Uistoryboardsegue文档的概述部分。
尝试以下:
NewsViewController *nVC = [self.storyboard instantiateViewControllerWithIdentifier:@"news"];
[self presentViewController:nVC animated:YES completion:NULL];
如果您不想通过故事板制作任何视图控制器,请使用XIB制作视图控制器。然后,将以下方法调用init实例。
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil;
选择单元格时,您可以使用以下方法来显示要显示的视图控制器。
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion