实际上,我遇到了一个神秘的问题。我正在尝试展示一个View Controller
UIModalPresentationFormSheet
,这是该类的代码
class AViewController: UIViewController
{
@IBOutlet weak var a: UILabel!
@IBOutlet weak var b: UILabel!
@IBOutlet weak var c: UILabel!
@IBOutlet weak var d: UISwitch!
@IBOutlet weak var f: UISwitch!
@IBOutlet weak var g: UISwitch!
@IBOutlet weak var e: UITextField!
var listOfCommentIds : [String]!
var AView : AASubViewController!
override func viewDidLoad()
{
super.viewDidLoad()
navigationController!.navigationBar.setBackgroundImage(UIImage(named: "navigation-bg-ios6"),
forBarMetrics: .Default)
navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Done, target: self, action: "dismiss")
navigationItem.rightBarButtonItem = UIBarButtonItem(title: "Send", style: UIBarButtonItemStyle.Done, target: self, action: "sendComment")
navigationItem.title = "Send Comment";
navigationController!.navigationBar.tintColor = UIColor.whiteColor()
var application: AppDelegate = UIApplication.sharedApplication().delegate as AppDelegate
var tababarController = application.tabBarController as UITabBarController
var selectedIndex = tabBarController!.selectedIndex
// self.adjustLayout()
// Do any additional setup after loading the view.
}
}
在尝试展示它时,应用程序在第二行崩溃,但viewDidLoad
有以下异常:
* thread #1: tid = 0x8ace, 0x000ef819 A`A.AAViewController.viewDidLoad (self=<unavailable>)() -> () + 3753 at AAViewController.swift:25, queue = 'com.apple.main-thread', stop reason = EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0)
* frame #0: 0x000ef819 A`A.AAViewController.viewDidLoad (self=<unavailable>)() -> () + 3753 at AAViewController.swift:25
frame #1: 0x020952a4 UIKit`-[UIViewController loadViewIfRequired] + 771
frame #2: 0x02095595 UIKit`-[UIViewController view] + 35
frame #3: 0x00474a8b A`-[CommentsSubViewController showSendEmailViewControllerWithListOfIds:](self=0x7d92ebe0, _cmd=0x00625884, listOfIds=0x7f38cc00) + 555 at CommentsSubViewController.m:1177
frame #4: 0x00473bce A`-[CommentsSubViewController sendEmailCommentButtonAction](self=0x7d92ebe0, _cmd=0x00625a6b) + 526 at CommentsSubViewController.m:1098
frame #5: 0x037907cd libobjc.A.dylib`-[NSObject performSelector:withObject:withObject:] + 84
frame #6: 0x01f3f23d UIKit`-[UIApplication sendAction:to:from:forEvent:] + 99
frame #7: 0x01f3f1cf UIKit`-[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
frame #8: 0x02072e86 UIKit`-[UIControl sendAction:to:forEvent:] + 69
frame #9: 0x020732a3 UIKit`-[UIControl _sendActionsForEvents:withEvent:] + 598
frame #10: 0x0207250d UIKit`-[UIControl touchesEnded:withEvent:] + 660
frame #11: 0x01f8f60a UIKit`-[UIWindow _sendTouchesForEvent:] + 874
frame #12: 0x01f900e5 UIKit`-[UIWindow sendEvent:] + 791
frame #13: 0x01f55549 UIKit`-[UIApplication sendEvent:] + 242
frame #14: 0x01f6537e UIKit`_UIApplicationHandleEventFromQueueEvent + 20690
frame #15: 0x01f39b19 UIKit`_UIApplicationHandleEventQueue + 2206
frame #16: 0x03a151df CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
frame #17: 0x03a0aced CoreFoundation`__CFRunLoopDoSources0 + 253
frame #18: 0x03a0a248 CoreFoundation`__CFRunLoopRun + 952
frame #19: 0x03a09bcb CoreFoundation`CFRunLoopRunSpecific + 443
frame #20: 0x03a099fb CoreFoundation`CFRunLoopRunInMode + 123
frame #21: 0x0867824f GraphicsServices`GSEventRunModal + 192
frame #22: 0x0867808c GraphicsServices`GSEventRun + 104
frame #23: 0x01f3d8b6 UIKit`UIApplicationMain + 1526
frame #24: 0x0012b2bc A`main(argc=1, argv=0xbff13614) + 76 at main.m:12
frame #25: 0x0452cac9 libdyld.dylib`start + 1
最奇怪的是当我注释掉以下行时:
var selectedIndex = tabBarController!.selectedIndex
这view controller
就像一个沙姆。
知道发生了什么吗?