uinavigationcontroller的异常行为点击UIButton会引发异常



5年前我一直在使用objective C,现在开始在Swift中工作。我面临着这种不正常的行为,谷歌了很多,但仍然没有得到解决方案,我在这里发帖,这样可能会发生在其他人身上,并可能帮助我解决这个问题!

场景是:我不是用故事板代替xibs。在AppDelegate中(roorviewcontroller是navigationcontroller)->主视图控制器加载成功->第二视图控制器也从主视图控制器成功加载,但从第二视图:我无法按下/弹出(点击按钮引发下降异常。你可以在你的端部测试这种情况,这不像我在更改ibaction或iboutlet等的文本。

在AppDelegate中:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
window = UIWindow.init(frame: UIScreen.mainScreen().bounds)
window?.backgroundColor = UIColor.whiteColor()
let mainViewController = MainViewController()
let navController = UINavigationController(rootViewController: mainViewController)
window!.rootViewController = navController
window!.makeKeyAndVisible()

In-ViewControllers:

@IBAction func nextScreen()
{
let loginViewController = UIViewController(nibName: "DViewController", bundle: nil)
navigationController?.pushViewController(loginViewController, animated: true, completion: nil)
}

堆栈跟踪:

-[UIViewController getTaf]: unrecognized selector sent to instance 0x7d961f10
2017-01-07 20:15:00.125 January7[5083:187391] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIViewController getTaf]: unrecognized selector sent to instance 0x7d961f10'
*** First throw call stack:
(
0   CoreFoundation                      0x002c2494 __exceptionPreprocess + 180
1   libobjc.A.dylib                     0x01fd9e02 objc_exception_throw + 50
2   CoreFoundation                      0x002cc253 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3   CoreFoundation                      0x0020189d ___forwarding___ + 1037
4   CoreFoundation                      0x0020146e _CF_forwarding_prep_0 + 14
5   libobjc.A.dylib                     0x01fee0b5 -[NSObject performSelector:withObject:withObject:] + 84
6   UIKit                               0x00ab4e38 -[UIApplication sendAction:to:from:forEvent:] + 118
7   UIKit                               0x00ab4db7 -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
8   UIKit                               0x00c58f3b -[UIControl sendAction:to:forEvent:] + 79
9   UIKit                               0x00c592d4 -[UIControl _sendActionsForEvents:withEvent:] + 433
10  UIKit                               0x00c582c1 -[UIControl touchesEnded:withEvent:] + 714
11  UIKit                               0x00b3552e -[UIWindow _sendTouchesForEvent:] + 1095
12  UIKit                               0x00b365cc -[UIWindow sendEvent:] + 1159
13  UIKit                               0x00ad7be8 -[UIApplication sendEvent:] + 266
14  UIKit                               0x00aac769 _UIApplicationHandleEventQueue + 7795
15  CoreFoundation                      0x001d4e5f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
16  CoreFoundation                      0x001caaeb __CFRunLoopDoSources0 + 523
17  CoreFoundation                      0x001c9f08 __CFRunLoopRun + 1032
18  CoreFoundation                      0x001c9846 CFRunLoopRunSpecific + 470
19  CoreFoundation                      0x001c965b CFRunLoopRunInMode + 123
20  GraphicsServices                    0x047d9664 GSEventRunModal + 192
21  GraphicsServices                    0x047d94a1 GSEventRun + 104
22  UIKit                               0x00ab2eb9 UIApplicationMain + 160
23  January7                            0x000cf781 main + 145
24  libdyld.dylib                       0x029f7a25 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

我们已经解决了这个问题,它可能会帮助一些人节省时间,它现在正在工作"通过用DViewController取代UIViewController!

相关内容

  • 没有找到相关文章

最新更新