2016-10-08 11 views
-1

나는 스토리 보드의 navigation controller 안에 viewcontroller를 가지고있다. viewcontroller에 tableview 항목이있다. 그래서 item의 onclick은 xib viewcontroller 인 viewcontroller를 제시해야한다. , 나는 예외가 발생하는 일부 코드를 시도했다.xib viewcontroller from storyboard 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) 
+0

마음을 읽거나 컴퓨터를 볼 수 없습니다. 당신은 우리에게 말해야 만합니다 : _ 당신은 예외가 있습니까? – matt

+1

그래서 이것은 당신이 보여준 코드와 아무런 관련이 없습니다. 문제는 xib가 잘못 구성되어 있다는 것입니다. 그것은'sendResponse' 콘센트를 가지고 있지만, 여러분의 ThirdViewController는'sendResponse' 속성을 가지고 있지 않습니다. – matt

+0

나는 이해했다, 나는 그것이 작동하고있는 연결을 제거했다 – skyshine

답변

0

ThirdViewController에는 sendResponse 속성이 없습니다. 그러므로 충돌.

내 생각은 어떻게 생겼는지에 대한 것입니다. xib에 단추를 구성 할 때 sendResponse콘센트으로 만들었습니다. 아마 액션이되기를 원했을 것입니다.