如何从storyboard viewcontroller调用xib viewcontroller

时间:2016-10-08 19:19:08

标签: ios storyboard xib

我是ios编程的新手,我在storyboard中的导航控制器内有viewcontroller,在那个viewcontroller我有tableview项目,所以onclick项目我必须提供一些viewcontroller这是xib viewcontroller,我尝试了一些代码我是得到例外。

    code:

         -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
                ThirdController *detailViewController = [[ThirdController alloc] initWithNibName:@"ThirdController" bundle:nil];

                [self.navigationController pushViewController:detailViewController animated:YES];

        }

exception:
SampleNaviationController[2499:84098] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ThirdController 0x7c02d9d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key sendResponse.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00b12a14 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x005d3e02 objc_exception_throw + 50
    2   CoreFoundation                      0x00b12631 -[NSException raise] + 17
    3   Foundation                          0x002691bc -[NSObject(NSKeyValueCoding) setValue:forUndefinedKey:] + 282
    4   Foundation                          0x001c383a _NSSetUsingKeyValueSetter + 115
    5   Foundation                          0x001c37bf -[NSObject(NSKeyValueCoding) setValue:forKey:] + 295
    6   UIKit                               0x0106506d -[UIViewController setValue:forKey:] + 85
    7   Foundation                          0x001f801d -[NSObject(NSKeyValueCoding) setValue:forKeyPath:] + 384
    8   UIKit                               0x012d8cb4 -[UIRuntimeOutletConnection connect] + 132
    9   libobjc.A.dylib                     0x005e800c -[NSObject performSelector:] + 62
    10  CoreFoundation                      0x00a42f51 -[NSArray makeObjectsPerformSelector:] + 273
    11  UIKit                               0x012d734e -[UINib instantiateWithOwner:options:] + 2102
    12  UIKit                               0x0106cabc -[UIViewController _loadViewFromNibNamed:bundle:] + 429
    13  UIKit                               0x0106d4f4 -[UIViewController loadView] + 189
    14  UIKit                               0x0106d900 -[UIViewController loadViewIfRequired] + 154
    15  UIKit                               0x01074406 -[UIViewController __viewWillAppear:] + 114
    16  UIKit                               0x010975b9 -[UIViewController(UIContainerViewControllerProtectedMethods) beginAppearanceTransition:animated:] + 202
    17  UIKit                               0x010a99cc -[UINavigationController _startCustomTransition:] + 1389
    18  UIKit                               0x010bb769 -[UINavigationController _startDeferredTransitionIfNeeded:] + 803
    19  UIKit                               0x010bcada -[UINavigationController __viewWillLayoutSubviews] + 68
    20  UIKit                               0x01298c4a -[UILayoutContainerView layoutSubviews] + 252
    21  UIKit                               0x00f6e008 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 810
    22  libobjc.A.dylib                     0x005e8059 -[NSObject performSelector:withObject:] + 70
    23  QuartzCore                          0x0492680a -[CALayer layoutSublayers] + 144
    24  QuartzCore                          0x0491a4ee _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 388
    25  QuartzCore                          0x0491a352 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    26  QuartzCore                          0x0490ce8b _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 317
    27  QuartzCore                          0x04940e03 _ZN2CA11Transaction6commitEv + 561
    28  QuartzCore                          0x04942674 _ZN2CA11Transaction17flush_transactionEv + 50
    29  UIKit                               0x00ed2dfa _afterCACommitHandler + 197
    30  CoreFoundation                      0x00a2bffe __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
    31  CoreFoundation                      0x00a2bf5e __CFRunLoopDoObservers + 398
    32  CoreFoundation                      0x00a218dc __CFRunLoopRun + 1340
    33  CoreFoundation                      0x00a210e6 CFRunLoopRunSpecific + 470
    34  CoreFoundation                      0x00a20efb CFRunLoopRunInMode + 123
    35  GraphicsServices                    0x041c0664 GSEventRunModal + 192
    36  GraphicsServices                    0x041c04a1 GSEventRun + 104
    37  UIKit                               0x00ea1bfa UIApplicationMain + 160
    38  SampleNaviationController           0x001017ba main + 138
    39  libdyld.dylib                       0x03184a21 start + 1
    40  ???                                 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

1 个答案:

答案 0 :(得分:0)

您的ThirdViewController中没有String q = "Select Column1, Column2 from TableName"; 属性;因此崩溃。

我猜这是怎么回事。在xib中配置按钮后,您将sendResponse设为 outlet 。您可能希望它是动作