Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7907911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T11:41:02+00:00 2026-06-03T11:41:02+00:00

So, I followed a tutorial concerning how to get a a UIDatePicker up instead

  • 0

So, I followed a tutorial concerning how to get a a UIDatePicker up instead of the keyboard when the user taps on a UITextField. The problem I’m getting is that when the picker comes up, it’s clipped and it gives this message in the console:

Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:].

I tried the other methods but they didn’t work either, nor did I expect them to. If anyone could take a look at the code below and offer some advice, that would be great. Thanks 🙂

AddShiftViewController.h

#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "Shift.h"

@interface AddShiftsViewController : UIViewController <UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *jobTitleField;
@property (weak, nonatomic) IBOutlet UITextField *startDateField;
@property (weak, nonatomic) IBOutlet UITextField *endDateField;

@property (nonatomic, strong) NSDate *startDate;
@property (nonatomic, strong) NSDate *endDate;

@property (nonatomic, strong) UIActionSheet *dateSheet;

- (void)setDate;
- (void)dismissPicker;
- (void)cancelPicker;

- (IBAction)addShift:(id)sender;

@end

AddShiftViewController.m

#import "AddShiftsViewController.h"

@interface AddShiftsViewController ()

@end

@implementation AddShiftsViewController
@synthesize jobTitleField;
@synthesize startDateField;
@synthesize endDateField;
@synthesize startDate, endDate, dateSheet;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    AppDelegate *dataCenter = (AppDelegate *)[[UIApplication sharedApplication] delegate];
}

- (void)viewDidUnload
{
    [self setJobTitleField:nil];
    [self setStartDateField:nil];
    [self setEndDateField:nil];
    [self setEndDate:nil];
    [self setStartDate:nil];
    [self setDateSheet:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

- (IBAction)addShift:(id)sender {
    Shift *newShift = [[Shift alloc] init];
}

- (void)setDate {
    dateSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];

    [dateSheet setActionSheetStyle:UIActionSheetStyleDefault];

    CGRect pickerFrame = CGRectMake(0, 44, 0, 0);
    UIDatePicker *picker = [[UIDatePicker alloc] initWithFrame:pickerFrame];
    [picker setDatePickerMode:UIDatePickerModeDateAndTime];

    [dateSheet addSubview:picker];

    UIToolbar *controlToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, dateSheet.bounds.size.width, 44)];

    [controlToolBar setBarStyle:UIBarStyleDefault];
    [controlToolBar sizeToFit];

    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    UIBarButtonItem *setButton = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleDone target:self action:@selector(dismissPicker)];

    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelPicker)];

    [controlToolBar setItems:[NSArray arrayWithObjects:spacer, cancelButton, setButton, nil] animated:NO];

    [dateSheet addSubview:controlToolBar];

    [dateSheet showInView:self.view];

    [dateSheet setBounds:CGRectMake(0, 0, 420, 385)];
}

- (void)dismissPicker {
    NSArray *listOfViews = [dateSheet subviews];
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"MMMM d, yyyy at H:mm"];

    for (UIView *subView in listOfViews) {
        if ([subView isKindOfClass:[UIDatePicker class]]) {
            if (self.startDateField.isEditing) {
                self.startDate = [(UIDatePicker *)subView date];
                [self.startDateField setText:[formatter stringFromDate:self.startDate]];
                [dateSheet dismissWithClickedButtonIndex:0 animated:YES];
            }
            else if (self.endDateField.isEditing) {
                self.endDate = [(UIDatePicker *)subView date];
                [self.endDateField setText:[formatter stringFromDate:self.endDate]];
                [dateSheet dismissWithClickedButtonIndex:0 animated:YES];
            }
        }
    }
}

-(BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
    [self setDate];
    return NO;
}

- (void)cancelPicker {
    [dateSheet dismissWithClickedButtonIndex:0 animated:YES];
}

@end

Shifts.h (custom class)

#import <Foundation/Foundation.h>

@interface Shift : NSObject

@property (nonatomic, strong) NSString *jobTitle;
@property (nonatomic, strong) NSString *employer;
@property (nonatomic, strong) NSDate *startDate;
@property (nonatomic, strong) NSDate *endDate;

@end

EDIT

So, I tried switching to:

[dateSheet showFromTabBar:self.tabBarController.tabBar];

But it still is clipping. I’ve attached a picture to show you exactly what’s happening.

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T11:41:03+00:00Added an answer on June 3, 2026 at 11:41 am

    It looks like you may have gotten the numbers on this line a bit off:

    [dateSheet setBounds:CGRectMake(0, 0, 420, 385)];
    

    Should be:

    [dateSheet setBounds:CGRectMake(0, 0, 320, 485)];
    

    The width of the iPhone screen isn’t 420 pixels 🙂 the classic screen is 320 wide (in portrait) or 640 wide on the Retina display. Although there could be an error somewhere else as well, this one stands out to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this tutorial and got problem that certificate has expired. I looked up
I followed this tutorial here: http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/ It works great but when I enable CSRF
I followed a tutorial that went like so: ajaxRequest.onreadystatechange = function(){ if(ajaxRequest.readyState == 4){
I have followed this tutorial which allowed me to create a Silverlight DataGrid that
I followed this tutorial: http://codeigniter.com/wiki/Internationalization_and_the_Template_Parser_Class/ The controller that loads the language is this one:
I have a compiling problem. I followed tutorial about Hello world program for Android
Followed this tutorial on getting autocomplete for CI to work with Eclipse http://taggedzi.com/articles/display/autocomplete-eclipse-codeigniter-2 -
I followed several tutorial to make this work, but I can't get draggable items.
Having followed a tutorial online, I have a sessions controller that looks like: class
I followed this tutorial with only one difference. Instead of naming it hello.php, I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.