tab bar controller tab items no longer clickable

Discussion in 'iOS Programming' started by johnmerlino, May 15, 2012.

  1. johnmerlino macrumors member

    Joined:
    Oct 22, 2011
    #1
    Hi all,

    I implemented a tab bar controller. One of the tab items takes user to a page where they can filter date ranges. When user selects in text field, rather than keyboard poppping up, a datepicker pops up and has a toolbar with a button item on it. When user clicks on button, the toolbar and datepicker are hidden. Problem is now when I try to select another tab bar item, it is no longer responsive.

    Here's my code:

    Code:
    - (void)viewDidLoad
    {
        [super viewDidLoad];
            
        self.datePicker = [[UIDatePicker alloc]init];
        [self.datePicker addTarget:self action:@selector(dateChanged:) forControlEvents:UIControlEventValueChanged];
        
        UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
        UIBarButtonItem *doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(addButtonPressed)];    
        
        [toolbar setItems:[NSArray arrayWithObject:doneButton]];
    
        self.dateToolbar = toolbar;
    
        self.historyDateSelect.inputView = self.datePicker;
        self.historyDateSelect.inputAccessoryView = self.dateToolbar;
    
        historyDateSelect.delegate=self;
        
    }
    
    - (void)addButtonPressed
    {
        self.dateToolbar.hidden=YES;
        self.datePicker.hidden=YES;
    }
    
    
    - (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
    {
        self.dateToolbar.hidden=NO;
        self.datePicker.hidden=NO;
    
        return YES;
    }
    
    thanks for response
     
  2. TheWatchfulOne macrumors 6502

    TheWatchfulOne

    Joined:
    Jun 19, 2009
    #2
    Resign First Responder?

    Should the datePicker maybe resign first responder?

    Code:
    [self.datePicker resignFirstResponder];
    I know this is true for the keyboard when you are ready to dismiss it. Maybe it's true for the date picker too?
     
  3. johnmerlino thread starter macrumors member

    Joined:
    Oct 22, 2011
    #3
    first responder was text field! So it worked when invoked on textfield instance.
     

Share This Page