Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I show a UIDatePicker inside a Popover on iPad using StoryBoard?
    primarykey
    data
    text
    <p>I have achieved to show the datepicker inside the popover, doing it programmatically as it is shown in <a href="https://stackoverflow.com/questions/7341835/uidatepicker-in-uipopover?rq=1">UIDatePicker in UIPopover</a>.</p> <p>But I have been trying to do it in interface Builder, I already made a View Controller named DatePickerViewController.m with a DatePicker in it and its corresponding IBoulet</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface DatePickerViewController : UIViewController @property (strong, nonatomic) IBOutlet UIDatePicker *birthdayDatePicker; @end </code></pre> <p><img src="https://i.stack.imgur.com/sXbDe.png" alt="DatePicker inside DatePickerViewController.m in StoryBoard"></p> <p>Then I need this to be shown in a popover when the Birthday text field is being edited. so I use the following code</p> <pre><code>- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField{ //Assign DatePicker to Birthday TextField //build our custom popover view DatePickerViewController* popoverContent = [[DatePickerViewController alloc] init]; //resize the popover view shown //in the current view to the view's size popoverContent.contentSizeForViewInPopover = CGSizeMake(320, 216); // dismiss existing popover if (self.popoverControllerBirthday) { [self.popoverControllerBirthday dismissPopoverAnimated:NO]; self.popoverControllerBirthday = nil; } //create a popover controller with my DatePickerViewController in it UIPopoverController *popoverControllerForDate = [[UIPopoverController alloc] initWithContentViewController:popoverContent]; //Set the delegate to self to receive the data of the Datepicker in the popover popoverControllerForDate.delegate = self; //Adjust the popover Frame to appear where I want CGRect myFrame =textField.frame; myFrame.origin.x = 260; myFrame.origin.y = 320; //Present the popover [popoverControllerForDate presentPopoverFromRect:myFrame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES]; self.popoverControllerBirthday = popoverControllerForDate; return NO; // tells the textfield not to start its own editing process (ie show the keyboard) } </code></pre> <p>And I also import the custom DatePickerViewController in my current ViewController</p> <pre><code>#import "DatePickerViewController.h" </code></pre> <p>But it is not showing the datepicker inside the popover. </p> <p><img src="https://i.stack.imgur.com/GvOdo.png" alt="enter image description here"></p> <p>Does anybody know what could be happening?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload