所以我正在使用 Storyboard和 xib。
我在我的 ViewController 中使用了一个 TableView ,它有一个自定义标题作为 xib 文件(VC 是文件所有者)。
我想在标题上滑动时显示我的新 VC,我使用 IB 向 xib 添加了滑动手势,但现在我无法显示它。
当我尝试实例化 ViewControllerWithIdentifier 时发生崩溃。我制作了我展示的 VC 的属性。并设置正确的标识符“swipeRight”。
- (IBAction)swipedRight:(id)sender {
NSLog(@"right");
if (_mpvc == nil) { //user those if only so the use wont push it twice and more
_mpvc = [self.storyboard instantiateViewControllerWithIdentifier:@"swipeRight"];
}
[self presentViewController:_mpvc animated:YES completion:nil];
}
错误:
Cannot find executable for CFBundle 0x9022120 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk/System/Library/AccessibilityBundles/GeoServices.axbundle> (not loaded)
最佳答案
如果您在 XIB 文件中,您如何知道您使用的是哪个 Storyboard?因此,首先您必须实例化 Storyboard,其中包含具有指定标识符的 viewController:
UIStoryboard *st = [UIStoryboard storyboardWithName:@"StoryboardName" bundle:nil];
在您必须使用您创建的这个 Storyboard实例化 viewController 之后:
UIViewController _mpvc = [st instantiateViewControllerWithIdentifier:@"swipeRight"];
最后你必须呈现 viewController:
[self presentViewController:_mpvc animated:YES completion:nil];
希望它能解决您的问题!
关于ios - 使用标识符实例化 ViewController 会导致使用 Storyboard 和 xib 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23219165/