【发布时间】:2015-05-27 15:25:53
【问题描述】:
我正在尝试将UISlider 添加到UIView 以添加到我的UIAlertController 以便更轻松但我不确定该方法。在 Objective C 中你会调用 addSubview 但我不确定它在 swift 中是什么。
//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)
【问题讨论】:
标签: ios swift uiview uiviewcontroller