Hey everyone!
I'm having a bit of an issue with an application I'm currently trying to build. The issue occurs when I get to a tutorial section within my applicaiton. The way I have this area setup, is with a Page View Controller and a main view (UIViewController) to maintain all of the logic behind the PageViewController and finally a content view (UIViewController) to hold all of the content for each page.
On the first page of my application, I ask for two dates within two different text fields. These dates are put in using the UIDatePicker. The issue arrises when the second text field is selected. For whatever reason, the text in the second UITextField is larger and bolder than in the previous one. I have checked the settings of the TextFields and they are identical. To make things even weirder, it doesn't matter which text filed I choose first, it will always have normal text while the other will have the oddly formatted text.
What can I do to solve this issue?
Thanks!🙂
P.S. The code for how the date picker is handled is below.
@IBAction func editingDateField(sender: UITextField) {
/
let inputView = UIView(frame: CGRectMake(0, 0, self.view.frame.width, 240))
inputView.backgroundColor = UIColor(white: 1, alpha: 0.5)
var datePickerView : UIDatePicker = UIDatePicker(frame: CGRectMake(0, 40, 0, 0))
datePickerView.datePickerMode = UIDatePickerMode.Date
inputView.addSubview(datePickerView) /
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) /
doneButton.addTarget(self, action: "doneButton:", forControlEvents: UIControlEvents.TouchUpInside) /
sender.inputView = inputView
datePickerView.addTarget(self, action: Selector("handleDatePicker:"), forControlEvents: UIControlEvents.ValueChanged)
handleDatePicker(datePickerView) /
}
@IBAction func editingDateField2(sender: UITextField) {
/
let inputView = UIView(frame: CGRectMake(0, 0, self.view.frame.width, 240))
inputView.backgroundColor = UIColor(white: 1, alpha: 0.5)
var datePickerView : UIDatePicker = UIDatePicker(frame: CGRectMake(0, 40, 0, 0))
datePickerView.datePickerMode = UIDatePickerMode.Date
inputView.addSubview(datePickerView) /
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) /
doneButton.addTarget(self, action: "doneButton2:", forControlEvents: UIControlEvents.TouchUpInside) /
sender.inputView = inputView
datePickerView.addTarget(self, action: Selector("handleDatePicker2:"), forControlEvents: UIControlEvents.ValueChanged)
handleDatePicker2(datePickerView) /
}
func handleDatePicker(sender: UIDatePicker) {
var dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle
var defaults: NSUserDefaults = NSUserDefaults.standardUserDefaults()
defaults.setValue(sender.date, forKey: defaultKeys.key4)
datePickerField.text = dateFormatter.stringFromDate(sender.date)
}
func handleDatePicker2(sender: UIDatePicker)
{
var dateFormatter = NSDateFormatter()
dateFormatter.dateStyle = NSDateFormatterStyle.MediumStyle
var defaults: NSUserDefaults = NSUserDefaults.standardUserDefaults()
defaults.setValue(sender.date, forKey: defaultKeys.key3)
date2PickerField.text = dateFormatter.stringFromDate(sender.date)
}
func doneButton(sender:UIButton)
{
datePickerField.resignFirstResponder() /
}
func doneButton2(sender: UIButton)
{
date2PickerField.resignFirstResponder() /
}