Lio*_*789 1 iphone xcode objective-c storyboard ios
我正在尝试使用此代码在我的故事板中实例化一个新的视图控制器,但它什么都不做,并保留在旧的故事板上.
这是代码:
(void)menuSelect:(id)sender {
UIButton *button = (UIButton*) sender;
switch (button.tag) {
case 0: {
HomeViewController *hc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Home"];
[self presentViewController:hc animated:YES completion:nil];
break;
}
Run Code Online (Sandbox Code Playgroud)
故事板文件名是Main.Storyboard,viewController的id是Profile.
以下是故事板的外观图像:

你正在传递"家"作为标识符HomeViewController,而它是"个人资料".所以你告诉程序的是:获取storyboard名称为"main",实例化HomeViewController标识符为"home".
将代码更改为:
HomeViewController *hc=[[UIStoryboard storyboardWithName:@"Main" bundle:nil] instantiateViewControllerWithIdentifier:@"Profile"];
[self presentViewController:hc animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
278 次 |
| 最近记录: |