UIDatePicker Shows Empty Picker view - ios

UIDatePicker Shows Empty Picker View. It's working perfect, I mean It is scrolling, It is setting date to respective textfield but in picker view it is not displaying date. I have attached a screenshot.
Code for DatePiker,
datePicker = [[UIDatePicker alloc]init];
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
[datePicker setDate:[NSDate date]];
_txtDue.inputView = datePicker;
Any help will be appreciated!

Finally I figure out it. It was a issue of one third party library called UIHidingView!! It was added by someone in this project. This library's description from github states that,
UIHidingView is an iOS class that displays UIView element on top UITableView which is hiding when Table View is scrolling
Now UIDatePicker internally used tableview in it so, it was hiding it's components!
PS : take care when using third party libraries!!

Related

UITapGestureRecognizer makes certain fields unclickable

I'm using a UITapGestureRecognizer on the lowest down view (self.view) to hide my keyboard.
UITapGestureRecognizer *tapHandler = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handleBackgroundTap:)];
[self.view addGestureRecognizer:tapHandler];
And the handleBackGroundTap method simply does
[self.view endEditing:YES];
And this code works fine on most of my views except for a couple
a view where i'm using a tableview populated with clickable items (it's a list of checkboxes really)
a view that uses a datepicker (the datepicker should open when you click the textfield)
On those two views said items become unresponsive: the checkboxes are unclickable (they don't mark or unmark when tapped) and the datepicker refuses to show.
My question is: why? And: are there any workarounds?
Note: if I don't add the gesture recognizer the fields work fine but not being able to dismiss the keyboard is rather annoying.
so as I was looking around i happened to stumble across a solution (which is typical... Have been searching for days and the moment I post a question I find the solution)
In any case adding
[tapHandler setCancelsTouchesInView:NO];
solved the issue
edit: I have to wait 2 days to accept this as the answer...

Changing UIDatePicker

I want to make a datePicker like the one in picture given below:
By UIDatePicker, as long I searched I think UIDatePicker doesn't provide this view. So, I have designed the above view by UIPickerView but my code is very messy and there are other requirements too with the picker now. Can you suggest some library for it?
using a UIDatePicker it is possible by changing the datePickerMode property:
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
More on the documentation
Also, if you want to change the order, you can set the localeproperty with a locale that has a different date format.

Formatting UITextField for time

I want to make a single UITextField that displays the format 00:00.00 where the : and . are permanently set. So the user will tap the text field to edit it, and instead of the textfield going blank, I would like it to be __:__.__ (the underscores are blanks) and the user can type two numbers for the minutes, automatically shift to the seconds, type two numbers, and then autoshift to the milliseconds. How can this be done?
Alternatively, you could just use a UIDatePicker:
UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:self.view.frame];
[self.view addSubview:picker];
This is also available for drag-and-drop in the storyboard.

add a commenting feature to my detailViewController

i'm fairly new to iOS development, i'm trying to add a commenting feature to my detailViewController but im haveing no luck i thought if i added a test area like so:
UITextView *txt = [[UITextView alloc]init];
//set frame
//add on view
[self.view addSubView:txt];
[txt release];
it would work but nope, its for image people upload and you know how it goes if someone taps the image in the tableview it navigates to the detailViewController and it does that and shows the image and the name of it the next couple of steps involve, number of likes, number of views but thats for later date but you get my drift so i'm trying to add a commenting feature to my detailViewController what am i not correctly what are the steps?

Setting custom font for UILabel appearance causes UIDatePicker bug

In my app delegate I set the font and fontColor of all UILabels using [UILabel apperance], but this is causing the font in my UIDatePicker to also change, which Apple don't allow, and for obvious reasons because it makes the datePicker buggy by changing to default font while scrolling and other inconsistent and unintended behaviour.
How do I ignore UIDatePicker to keep it default when setting all UILabels?
I haven't found a "proper" solution for this problem short of abandoning UIDatePicker or [UILabel appearance], but I did figure out a hack that at least hides the problem. It seems that when the view is initially loaded, the UILabels holding the text for the selected date may be drawn using the label's appearance proxy, but when the UIDatePicker redraws after having the date reset, it will set the label back to the system font.
To hide the problem, in viewWillAppear:, I set the date to two different date values with different date components, then set the picker back to the proper date, like so:
[datePicker setDate:[NSDate dateWithTimeIntervalSince1970:0] animated:NO]; //1970-01-01
[datePicker setDate:[NSDate dateWithTimeIntervalSince1970:49000000] animated:NO]; //1971-07-22
[datePicker setDate:myDate animated:NO]; //Set back to the correct date
It's not elegant, but it makes the date picker look normal again.
The only simple work-around I found was to create the UIDatePicker in code (not using storyboards). I got what I wanted.
Try this ..
[[UILabel appearance] setTextColor:[UIColor redColor]];
[[UILabel appearance] setFont:[UIFont boldSystemFontOfSize:20.0f]];
[[UILabel appearanceWhenContainedIn:[UIDatePicker class],nil] setTextColor:nil];// default is nil (text draws black)
[[UILabel appearanceWhenContainedIn:[UIDatePicker class],nil] setFont:nil];// default is nil (system font 17 plain)
This will change all labels to red colour and their font except the UIDatePicker one. Hope this helps.
Red colour and bold font are for demonstration purposes. They should be as per your requirement.

Resources