How to set the date and time programmatically in iOS
You can't set the date and/or time on iPhone/iPad programmatically. Those APIs are considered protected by Apple. In other words if you were to use those APIs and submit an app using them it would be rejected.
Edit:
To get documentation on this you can contact Apple Developer Technical Support using one of your free tech support incidents included with your developer program. LINK
programmatically setting DatePicker time to current time
setDate:
method is used for setting specific date
[yourDatePicker setDate:[NSDate date]];
It will set picker date and time to current date and time.
How to get the value of General - Date & Time - Set Automatically programmatically in the iphone?
There is no way to get the value of that setting. Even if you could, it wouldn't mean anything at times because the user could be out of cell coverage meaning the time may not be accurate anyway.
How to create an iOS Time Picker programmatically?
This is what I ended up doing:
I found this popover solution -> https://github.com/werner77/WEPopover
That created the popover I wanted, then added this bit of code to the
- (void)viewDidAppear:(BOOL)animated method
// place inside a temporary view controller and add to popover
UIViewController *viewCon = [[UIViewController alloc] init];
// PopOverViewController *viewCon = [[PopOverViewController alloc] init];
UIDatePicker *timePick;
timePick = [[UIDatePicker alloc]initWithFrame:CGRectMake(5, 0, 0, 0)];
timePick.datePickerMode =UIDatePickerModeTime;
[viewCon.view addSubview:timePick];
// viewCon.view = label;
viewCon.contentSizeForViewInPopover = timePick.bounds.size ; // Set the content size
popover = [[WEPopoverController alloc] initWithContentViewController:viewCon];
[popover presentPopoverFromRect:CGRectMake(0, 10, 0, 120)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionUp | UIPopoverArrowDirectionDown
animated:YES];
The only problem now is resizing the picker to the width that I want....other than that, it works!
The solutions that were presented will only work for an iPad not an iPhone....
Thanks everyone.
Related Topics
Cannot Call Value of Non-Function Type 'Module<Firebase>'
Ar Refernce Image Plane Was Not Position Properly in iOS Swift
Force Wkwebview to Show Mobile Version
Receive Signal from Beacon While App Is in the Background
Ad-Hoc Distributed Application Failed to Launch in Time
iPhone /iOS: Presenting HTML 5 Keyboard for Postal Codes
How to Detect If The HTML5 Autoplay Attribute Is Supported
Allow Zooming Within Iframe But Not on Page in iOS
Why Does 'Position:Fixed' Not Work When Viewed in an 'Iframe' Using an iPhone or iOS Device
iOS 8 and Xcode 6 Simulator Display Out of Alignment
How to Change Select Box Background Without Losing The Right Arrow on Mobile Safari
Mobile Safari: Inertia Scrolling on Body and Minimal UI Behavior
iOS Uitableview Accessibility Order Is Wrong After Setting Accessibilityelements on Uitableviewcell
App Could Not Authenticate with Facebook and Firebase After Conversion to Swift 3 Syntax