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

  • Home
  • SEARCH
  • 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 8612995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:45:50+00:00 2026-06-12T04:45:50+00:00

I shift a modal view up when the keyboard is displayed to prevent some

  • 0

I shift a modal view up when the keyboard is displayed to prevent some parts of the interface being hidden by the keyboard.

When the view has been shifted, the toolbar cancel / save buttons don’t respond to taps. Taps inside the modal are detected and respond fine.

enter image description here

I’ve set it up so that the keyboard should dismiss when tapping outside the textfield, but this doesn’t work when tapping on the navigation bar either.

How can I respond appropriately to taps on barbuttonitems when the view has been offset?

Here’s how I am shifting the modal up when the keyboard is displayed:

- (void) animateTextField: (UITextField*) textField up: (BOOL) up
{
    int movementDistance;
    float movementDuration;

    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {

        if(
           UIInterfaceOrientationIsLandscape(self.interfaceOrientation)
          )
        { 
            //code for landscape shift - not relevant because you can't see the toolbar
       else{
            NSLog(@"Portrait for animation");
            movementDistance = IPAD_PORTRAIT_KEYBOARD_HEIGHT; 
            movementDuration = KEYBOARD_ANIMATION_DURATION; 

            if(up){
                keyboardAppearedInLandscape = false;   
            }else{
                //the keyboard is going down
                NSLog(@"Keyboard going down");
                //is the iPad in the same orientation now that it was when it came up?
                if ([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait || [[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortraitUpsideDown) 
                {
                    if (!keyboardAppearedInLandscape) {
                        //don't do anything - the keyboard is being dismissed in the same way it was called. It's much the same in any case.
                    }else{
                        movementDistance = IPAD_LANDSCAPE_KEYBOARD_HEIGHT;
                    }
                }
            }
        }

    } 
    int movement = (up ? -movementDistance : movementDistance);

    [UIView beginAnimations: @"anim" context: nil];
    [UIView setAnimationBeginsFromCurrentState: YES];
    [UIView setAnimationDuration: movementDuration];
    self.view.frame = CGRectOffset(self.view.frame, 0, movement);
    [UIView commitAnimations];
}
//end text field movy-ness

And here is how I am detecting taps outside the textfield to dismiss the keyboard:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
    if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {      
        //keyboard goes away if you tap somewhere else on screen
        NSLog(@"resignFirstResponder");
        [self.view endEditing:YES];

    }

    [super touchesBegan:touches withEvent:event];

}
  • 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-12T04:45:51+00:00Added an answer on June 12, 2026 at 4:45 am

    You won’t receive touch events outside the original rectangle bounds, because…

    • SuperView thinks that the view hasn’t changed location
    • View is moving up within itself instead of from outside
    • Visual elements on the screen are changing but aren’t being recognized

    Instead, to move the subview properly:

    1. SuperView should be responding to the UIKeyboard
      • Utilize UIKeyboardWillHideNotification && UIKeyboardWillShowNotification
    2. Set ClipsToBounds to YES
      • Now you won’t see stuff that’s outside of the view’s bounds.
      • Makes debugging more effective

    Check out:

    • Add done button to a UINavigationBar @StackOverflow
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I try to show some view in modal mode over the detailed view
I declared a global shift operator but for some reason the compiler cannot deduct
Some Background: ASP.net MVC is primarly a paradigm shift in the way you structure
I have a tab bar application and when I display a modal view controller,
I have a very strange issue here. I am using a present modal view
I'm starting to learn about MVC-based applications being that I'm getting into some heavier
The SSE shift instructions I have found can only shift by the same amount
The use of shift + scroll wheel is fairly common for horizontal scrolling. Both
On left shift of (char) 0xff by 8 and casting it to int we
How do I bitwise shift right/left in VB.NET? Does it even have operators for

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.