将XIB中的按钮链接到Storboard电子邮件中的视图控制器

时间:2014-03-30 20:21:42

标签: objective-c xcode uiviewcontroller xib xcode-storyboard

我有一个带有按钮的XIB viewcontroller。我还有一个storboard viewcontroller。我想知道是否有办法将xib视图控制器中的按钮链接到storyboard视图控制器。

错误

2014-03-30 16:44:30.597 HandMandy [2364:70b] *由于未捕获的异常终止应用' NSUnknownKeyException',原因:' [setValue:forUndefinedKey:] :此类不是键值视图的键值编码兼容。' * 第一次抛出调用堆栈: (     0 CoreFoundation 0x0000000101c1b795 exceptionPreprocess + 165     1 libobjc.A.dylib 0x0000000101725991 objc_exception_throw + 43     2 CoreFoundation 0x0000000101c9fe69 - [NSException raise] + 9     3基金会0x000000010130703a - [NSObject(NSKeyValueCoding)setValue:forKey:] + 259     4 CoreFoundation 0x0000000101c17700 - [NSArray makeObjectsPerformSelector:] + 224     5 UIKit 0x00000001005d11b8 - [UINib instantiateWithOwner:options:] + 1131     6 UIKit 0x00000001005d2bb2 - [NSBundle(UINSBundleAdditions)loadNibNamed:owner:options:] + 138     7 UIKit 0x000000010038781d - [UIApplication _loadMainNibFileNamed:bundle:] + 42     8 UIKit 0x0000000100386b1a - [UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 454     9 UIKit 0x0000000100397aab - [UIApplication handleEvent:withNewEvent:] + 3092     10 UIKit 0x0000000100397f1e - [UIApplication sendEvent:] + 79     11 UIKit 0x00000001003882be _UIApplicationHandleEvent + 618     12 GraphicsServices 0x0000000104977bb6 _PurpleEventCallback + 762     13 GraphicsServices 0x000000010497767d PurpleEventCallback + 35     14 CoreFoundation 0x0000000101b9d819 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 41     15 CoreFoundation 0x0000000101b9d5ee __CFRunLoopDoSource1 + 478     16 CoreFoundation 0x0000000101bc6ab3 __CFRunLoopRun + 1939     17 CoreFoundation 0x0000000101bc5f33 CFRunLoopRunSpecific + 467     18 UIKit 0x00000001003864bd - [UIApplication _run] + 609     19 UIKit 0x0000000100388043 UIApplicationMain + 1010     20 HandyMandy 0x0000000100000ea3 main + 115     21 libdyld.dylib 0x00000001032755fd start + 1     )     libc ++ abi.dylib:以NSException类型的未捕获异常终止

1 个答案:

答案 0 :(得分:0)

首先,在故事板中单击要显示的视图控制器。

然后在Identity Inspector 下,在storyboard ID中,为视图控制器提供ID。

然后在您的XIB视图控制器中的IBAction中执行以下操作:

//Create an instance of the storyboard
UIStoryboard *sb = [UIStoryboard storyboardWithName:@"StoryboardName" bundle:nil];
//Create the view controller
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:@"StoryboardID"];
//Present the view controller
[self presentViewController:vc animated:YES completion:nil];

这将以模态方式显示视图控制器。