启动时出现空白白屏但在预览iOS swift时很好

时间:2016-02-15 18:17:50

标签: ios swift

我的档案就是这样

main.Storyboard

import UIKit

class ViewController: UIViewController {


    @IBOutlet weak var pctA: UITextField!
    @IBOutlet weak var pctF: UITextField!
    @IBOutlet weak var pctM: UITextField!
    @IBOutlet weak var maxA: UITextField!
    @IBOutlet weak var maxM: UITextField!
    @IBOutlet weak var maxF: UITextField!
    @IBOutlet weak var ptsF: UITextField!
    @IBOutlet weak var ptsM: UITextField!
    @IBOutlet weak var ptsA: UITextField!
    @IBOutlet weak var creditNum: UITextField!
    @IBOutlet weak var courseTitle: UITextField!
    @IBOutlet weak var bbTFone: UITextField!
    @IBOutlet weak var bbTFtwo: UITextField!
    @IBOutlet weak var bbTFthree: UITextField!
    @IBOutlet weak var bbTFfour: UITextField!
    @IBOutlet weak var bbImgOne: UIImageView!
    @IBOutlet weak var bbImgTwo: UIImageView!
    @IBOutlet weak var bbImgThree: UIImageView!
    @IBOutlet weak var bbImageFour: UIImageView!


class course {

    var percentA:Int
    var percentF:Int
    var percentM:Int
    var maxAssignment:Int
    var maxFinal:Int
    var maxMidterm:Int
    var pointsA:Int
    var pointsF:Int
    var pointsM:Int
    var numofCredits:Int
    var courseName:String


    init (courseName: String, numofCredits: Int, pointsM: Int, pointsF: Int, pointsA: Int, maxMidterm: Int, maxFinal: Int, maxAssignment: Int, percentA: Int, percentF: Int, percentM: Int) {

        self.courseName = courseName
        self.numofCredits = numofCredits
        self.pointsM = pointsM
        self.pointsF = pointsF
        self.pointsA = pointsA
        self.maxMidterm = maxMidterm
        self.maxFinal = maxFinal
        self.maxAssignment = maxAssignment
        self.percentA = percentA
        self.percentF = percentF
        self.percentM = percentM

    }

}



@IBAction func addCourse(sender: AnyObject) {

    let newCourse = course(courseName: courseTitle.text!, numofCredits: Int(creditNum.text!)!, pointsM: Int(creditNum.text!)!, pointsF: Int(creditNum.text!)!, pointsA: Int(creditNum.text!)!, maxMidterm: Int(creditNum.text!)!, maxFinal: Int(creditNum.text!)!, maxAssignment: Int(creditNum.text!)!, percentA: Int(creditNum.text!)!, percentF: Int(creditNum.text!)!, percentM: Int(creditNum.text!)! )


    var courseArray = [newCourse]

    var assignmentPts = ((newCourse.pointsA)/(newCourse.maxAssignment) * newCourse.percentA)

    var midtermPts = ((newCourse.pointsA)/(newCourse.maxAssignment) * newCourse.percentA)

    var finalPts = ((newCourse.pointsA)/(newCourse.maxAssignment) * newCourse.percentA)

    var totalPts = assignmentPts + midtermPts + finalPts



    func appendtoBB() {



        for (var index = 0; index < 4; index++) {

        if bbTFone == nil {

            self.bbTFone.text = courseArray[0].courseName

        } else if (bbTFtwo == nil) {

            self.bbTFtwo.text = courseArray[1].courseName

        } else if (bbTFthree == nil) {

            self.bbTFthree.text = courseArray[2].courseName

        } else {

            self.bbTFfour.text = courseArray[3].courseName

        }

        }


    }



    func courseGrade() {



        if totalPts > 90 {

            bbImgOne.image = UIImage(named: "grade_a")

        } else if totalPts > 80 {

            bbImgTwo.image = UIImage(named: "grade_b")

        } else if totalPts > 70 {

            bbImgTwo.image = UIImage(named: "grade_c")

        } else if totalPts > 60 {

            bbImgTwo.image = UIImage(named: "grade_d")

        } else {

            bbImgTwo.image = UIImage(named: "grade_f")

        }


    }


    appendtoBB()
    courseGrade()


}




override func viewDidLoad() {
    super.viewDidLoad()
    // Do any additional setup after loading the view, typically from a nib.
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

的AppDelegate

import UIKit

  @UIApplicationMain
  class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    // Override point for customization after application launch.
    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:.
}




}

当我模拟我的应用程序时,我最初在启动时有一个空白的白色屏幕而不是在预览中它显示我的mainStoryboard作为启动屏幕。我已将Launch Screen File Base Name定义为:main和file storyboard文件基本名称为:main。此外,当应用程序运行时,我会生成一条警告,上面写着&#34;线程1:信号SIGABRT&#34;

有人能指出我正确的方向吗?谢谢!

0 个答案:

没有答案