-2

I have a XIB viewcontroller with a button in it. I also have a storboard viewcontroller. I would like to know if there is a way to link a button from the xib view controller to the storyboard viewcontroller.

The error

2014-03-30 16:44:30.597 HandMandy[2364:70b] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key view.' * First throw call stack: ( 0 CoreFoundation 0x0000000101c1b795 exceptionPreprocess + 165 1 libobjc.A.dylib 0x0000000101725991 objc_exception_throw + 43 2 CoreFoundation 0x0000000101c9fe69 -[NSException raise] + 9 3 Foundation 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: terminating with uncaught exception of type NSException

  • Word to the wise: don't leave your email address all over the internet at your age. – CodaFi Mar 30 '14 at 20:31
  • It's okay cuz its not even my real name but it is my email address. – user3466875 Mar 30 '14 at 20:36
  • 1
    Also this site is used best when the answers to questions are provided on the site. Do not ask people to email you. If the answer is too long for the answer box this site is probably the wrong place to be. – jackslash Mar 30 '14 at 20:40

1 Answers1

0

First, in your storyboard click the view controller you want to present.

Then under the Identity Inspector , in storyboard ID, give your view controller an ID.

Then in the IBAction in your XIB view controller for your button do:

//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];

This will present the view controller modally.

Milo
  • 5,041
  • 7
  • 33
  • 59