应用程序打开启动屏幕但崩溃(在iOS设备上)

时间:2016-04-06 12:24:21

标签: ios swift testflight

我在尝试在物理设备上测试我的应用时遇到了一些麻烦。每次我通过TestFlight测试我的应用程序时,它只会瞬间打开LaunchScreen然后崩溃。这很奇怪,因为它在模拟器中完美运行。

我没有使用StoryBoards,我已经阅读过,人们说要摆脱info.plist中的所有主要故事板引用和构建设置。我已经这样做了,但仍然无法正常工作。

我在下面附上了截图:

的Info.plist

enter image description here

构建设置

enter image description here

另外,我觉得这可能与我的AppDelegate有关,因为我试图以编程方式做所有事情。

AppDelegate.swift

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate 
{
    var window: UIWindow?

    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool 
    {
        // Override point for customization after application launch.
        self.window = UIWindow(frame:UIScreen.mainScreen().bounds)

        let navController = UINavigationController()
        let mainViewController = ViewController(nibName:nil, bundle:nil)

        // NavigationBar/Title colour
        navController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]
        UINavigationBar.appearance().barTintColor = UIColor(red:3/255, green:60/255, blue:115/255, alpha:1);


        // Push the viewcontroller onto the navigation controller
        navController.pushViewController(mainViewController, animated:false)

        self.window!.rootViewController = navController
        self.window?.makeKeyAndVisible()

        return true
    }

    func applicationWillResignActive(application: UIApplication) 
    {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(application: UIApplication) 
    {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(application: UIApplication) 
    {
        // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(application: UIApplication) 
    {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(application: UIApplication) 
    {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }
}

ViewController.swift - ViewDidLoad()

override func viewDidLoad() 
    {
        super.viewDidLoad()

        self.title = "MyApp"
        self.view.backgroundColor = UIColor.whiteColor()
        self.navigationController!.navigationBar.barTintColor = UIColor(red: 0, green: 40/255, blue: 99/255, alpha: 1)
        self.navigationController!.navigationBar.tintColor = UIColor.whiteColor()


        // container
        mainContainer = UIView()

        // button
        btn_Schedule = UIButton()
        btn_Career = UIButton()
        btn_Social = UIButton()
        btn_Feedback = UIButton()
        btn_Details = UIButton()

        // Label
        lbl_Copywrite = UILabel()

        // Horizontal Dividing lines
        dividingLineTop = UIView()
        dividingLineBottom = UIView()

        // images
        img_Schedule = UIImage()
        img_Career = UIImage()
        img_Social = UIImage()
        img_Feedback = UIImage()
        img_Details = UIImage()

        img_Schedule = UIImage(named:"imgschedule.PNG")
        img_Career = UIImage(named:"imgcareer.PNG")
        img_Social = UIImage(named:"imgsocial.PNG")
        img_Feedback = UIImage(named:"contact.PNG")
        img_Details = UIImage(named:"imgdetails.PNG")

        // set up button clicks
        btn_Schedule.addTarget(self, action:"onMyScheduleButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside)
        btn_Career.addTarget(self, action:"onMyCareerButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside)
        btn_Social.addTarget(self, action:"onMySocialButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside)
        btn_Feedback.addTarget(self, action:"onFeedbackButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside)
        btn_Details.addTarget(self, action:"onMyDetailsButton_Clicked:", forControlEvents: UIControlEvents.TouchUpInside)

        if UIDevice.currentDevice().orientation.isLandscape.boolValue
        {
            displayMenuInLandscapeMode()
        }
        else 
        {
            if(UIDevice.currentDevice().userInterfaceIdiom == UIUserInterfaceIdiom.Pad)
            {
                displayMenuInLandscapeMode()
            }
            else
            {
                displayMenuInPortraitMode()
            }
        }
    }

如果有人能提供帮助那就太棒了......过去几天一直坚持这个问题,我需要完成这个项目。

谢谢!

1 个答案:

答案 0 :(得分:0)

我知道这很荒谬,但是请删除navController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]。 我有同样的问题。一切都在本地运行,但不能在TestFlight上运行。

您可以通过设置navigationBar.barStyle = UIBarStyle.black

来更改标题的颜色