I am new to XCode and Swift.
I am building an App with a dataPickerView so that user to set date easily. The problem now is the code from "another question I ask" works fine in iPhone (see the image below), but when i test it in iPad, it become bad.
So how can I fix the code and make it a better look?
Here is the code:
@IBAction func dateTextInputPressed(sender: UITextField) {
//Create the view
let inputView = UIView(frame: CGRectMake(0, 0, self.view.frame.width, 240))
var datePickerView : UIDatePicker = UIDatePicker(frame: CGRectMake(0, 40, 0, 0))
datePickerView.datePickerMode = UIDatePickerMode.Date
inputView.addSubview(datePickerView) // add date picker to UIView
//let doneButton = UIButton(frame: CGRectMake(110, 0, 100, 50))
let doneButton = UIButton(frame: CGRectMake((self.view.frame.size.width/2) - (100/2), 0, 100, 50))
doneButton.setTitle("done", forState: UIControlState.Normal)
doneButton.setTitle("done", forState: UIControlState.Highlighted)
doneButton.setTitleColor(UIColor.blackColor(), forState: UIControlState.Normal)
doneButton.setTitleColor(UIColor.grayColor(), forState: UIControlState.Highlighted)
inputView.addSubview(doneButton) // add Button to UIView
doneButton.addTarget(self, action: "doneButton:", forControlEvents: UIControlEvents.TouchUpInside) // set button click event
sender.inputView = inputView
datePickerView.addTarget(self, action: Selector("handleDatePicker:"), forControlEvents: UIControlEvents.ValueChanged)
handleDatePicker(datePickerView) // Set the date on start.
}
Thanks!
PS: Sorry for my bad English. :(