1
我想添加一個UISlider
到UIView
添加到我的UIAlertController
爲更容易,但我不確定的方法。在目標C中,您可以撥打addSubview
,但我不確定它是什麼。添加UISlider到UIView
//UIViewController.alertReminden(timeInterval)
var refreshAlert = UIAlertController(title: "Reminder", message: "Set a reminder for the bus in \(self.timeInterval) minutes.", preferredStyle: UIAlertControllerStyle.Alert)
refreshAlert.addAction(UIAlertAction(title: "Ok", style: .Default, handler: { (action: UIAlertAction!) in
Alarm.createReminder("Catch the Bus",
timeInterval: NSDate(timeIntervalSinceNow: Double(self.timeInterval * 60)))
}))
refreshAlert.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: { (action: UIAlertAction!) in
println("Handle Cancel Logic here")
}))
var view = UIViewController();
var myFrame = CGRectMake(10.0, 10.0, 250.0, 25.0)
var slider = UISlider(frame: myFrame)
slider.minimumValue = 1
slider.maximumValue = 50
slider.value = Float(timeInterval)
view.addSubview(slider)
refreshAlert.addChildViewController(view)
self.viewForBaselineLayout()!.parentViewController?.presentViewController(refreshAlert, animated: true, completion: nil)
這的確然而工作的看法仍然不顯示在UIAlertController – applejuiceteaching
你有沒有嘗試'refreshAlert.addSubView(view.view)'? – Chackle
UIAlertController沒有addSubView方法只有refreshAlert.addChildViewController()需要一個UIViewController而不是UIView – applejuiceteaching