我在尝试在物理设备上测试我的应用程序时遇到了一些麻烦。每次我通过 TestFlight
测试我的应用程序时,它只会打开 LaunchScreen
一瞬间然后崩溃。这很奇怪,因为它在模拟器中完美运行。
我没有使用 StoryBoards
,我四处阅读,有人说要去掉 info.plist 中所有主要的
和build设置。我已经这样做了,但仍然无法正常工作。 Storyboard
引用
我在下面附上了屏幕截图:
信息.plist
build设置
另外,我觉得这可能与我的 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()
}
}
}
如果有人能提供帮助那就太好了。
最佳答案
我知道这很荒谬,但删除了 navController.navigationBar.titleTextAttributes = [NSForegroundColorAttributeName:UIColor.whiteColor()]
。
我有同样的问题。一切都在本地工作,但在 TestFlight 上不行。
您可以通过设置 navigationBar.barStyle = UIBarStyle.black
关于ios - 应用程序打开启动屏幕但崩溃(在 iOS 设备上),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36451088/