gpt4 book ai didi

ios - 模拟器黑屏(viewDidLoad)?

转载 作者:行者123 更新时间:2023-11-28 08:53:44 25 4
gpt4 key购买 nike

我搜索了一下,似乎无法弄清楚为什么我的模拟器运行时屏幕是黑色的。版权页面仍然加载,但它之后的 View 是黑色的。我认为这可能与 viewdidLoad() 有关。我可能是错的,因为我是 Swift 的新手。请帮我。谢谢。

import UIKit

class ViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet var Picker: UIPickerView!
@IBOutlet var Button: UIButton!
var PlacementAnswer = 0

var Array = ["First View Controller", "Second View Controller"]

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

Picker.delegate = self
Picker.dataSource = self
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func pickerView(pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String! {
return Array [row]
}
func pickerView(pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
return Array.count
}
func numberOfComponentsInPickerView(pickerView: UIPickerView) -> Int {
return 1
}
@IBAction func Select(sender: AnyObject){

if (PlacementAnswer == 0){
performSegueWithIdentifier("FirstView", sender: sender)
}else{
performSegueWithIdentifier("SecondView", sender: sender)
}
return
}

func pickerView(pickerView: UIPickerView, didSelectRow row: Int, inComponent component: Int) {
NSLog("Hello")
PlacementAnswer = row
}
}

最佳答案

确保 Storyboard中的所有 View 都连接到正确的 Controller 类,并且您已在 Storyboard中设置入口点 View 。我看到有几个人不幸地从 Storyboard 中删除了入口点。 (小右指示 Storyboard中的箭头)

关于ios - 模拟器黑屏(viewDidLoad)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33621842/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com