我有一个UIViewController
,它有一个按钮,我在StoryBoard
中创建了两个视图控制器,并将它连接到Cocoa类。我想将UIViewController
更改为两个视图控制器之一取决于某些条件。
我试过了:
// 1
BOOL isLoggedIn=TRUE;
NSString *storyboardId = isLoggedIn ? @"FirstViewController" : @"SecondViewController";
self.view = [self.view.inputViewController.storyboard instantiateViewControllerWithIdentifier:storyboardId];
// 2
[self.view addSubview:FirstViewController];
我很感激您的快速回复
答案 0 :(得分:1)
从StoryBoardID
选择子视图控制器,在右侧菜单中选择身份检查器,将ViewController *NVC = [self.storyboard instantiateViewControllerWithIdentifier:@"someID"];
[self presentViewController:NVC animated:YES completion:nil];
更改为 someID
然后,将此代码添加到按钮操作方法:
Try
'your code here for saving
Catch ex As Exception
msgbox("Error occured: " & ex)
'delete the excel file here.
End Try
答案 1 :(得分:0)
我认为您不理解UIView
和UIViewController
之间的区别。以下是您应该从SO发布的帖子:When to use a UIView vs. a UIViewController on the iPhone?