0
請考慮下面的代碼:iOS版雨燕按鈕顯示延遲
override func viewDidLoad() {
super.viewDidLoad()
let images = [
"Add To Inventory","Move To Display Room","Move To Store Room","Move To Storage","Scrap Inventory"
]
var buttons:[UIButton] = []
// For use in foreground
let name=defaults.valueForKey("name") as! String
tasksTitle.title = "Tasks for \(name)"
var y=CGFloat(140)
for var i=0;i<images.count;i++ {
print(i)
buttons.append(UIButton(type: .Custom))
buttons[i].frame = CGRectMake(60,y,650,100)
buttons[i].setImage(UIImage(named: "\(images[i]).png"), forState: .Normal)
buttons[i].tag = i
buttons[i].addTarget(self, action: "taskPressed:", forControlEvents: UIControlEvents.TouchUpInside)
self.view.addSubview(buttons[i])
y+=130
print(y)
}
我的問題是,它需要大約20秒的按鈕出現,當他們這樣做只是第一(添加到庫存)和最後(廢料庫存)實際上出現。我已經嘗試重新創建視圖並使用普通按鈕獲得相同的結果。有沒有人有任何想法,因爲我的問題可能是什麼?
圖像在包中,但很大(650x100)。我沒有考慮過。我會盡量縮小它們的尺寸,看看會發生什麼。 –