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 7854277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T20:00:24+00:00 2026-06-02T20:00:24+00:00

I have this method in a class. How do I use it in my

  • 0

I have this method in a class. How do I use it in my subclass (of this class) because when I call [self shiftViewUpForKeyboard]; it needs the argument but when I type theNotification, it gives an error. I know this is probably extremely basic, but it would really help me out a lot throughout the whole of my app.

- (void) shiftViewUpForKeyboard: (NSNotification*) theNotification;
{


    CGRect keyboardFrame;
    NSDictionary* userInfo = theNotification.userInfo;
    keyboardSlideDuration = [[userInfo objectForKey: UIKeyboardAnimationDurationUserInfoKey] floatValue];
    keyboardFrame = [[userInfo objectForKey: UIKeyboardFrameBeginUserInfoKey] CGRectValue];

    UIInterfaceOrientation theStatusBarOrientation = [[UIApplication sharedApplication] statusBarOrientation];

    if UIInterfaceOrientationIsLandscape(theStatusBarOrientation)
        keyboardShiftAmount = keyboardFrame.size.width;
    else 
        keyboardShiftAmount = keyboardFrame.size.height;

    [UIView beginAnimations: @"ShiftUp" context: nil];
    [UIView setAnimationDuration: keyboardSlideDuration];
    self.view.center = CGPointMake( self.view.center.x, self.view.center.y - keyboardShiftAmount);
    [UIView commitAnimations];
    viewShiftedForKeyboard = TRUE;

}

Thank you kindly!

  • 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-02T20:00:31+00:00Added an answer on June 2, 2026 at 8:00 pm

    This looks like a notification handler. You should generally not call notification handlers on your own. Notification handler methods usually are called by a notification emitted by NSNotificationCenter. The notification center sends an NSNotification object to the handler method. In your case, the notification includes some additional user info.

    You could resemble the user info dictionary in your code that should directly call the handler and pass that to the handler method (building up your own NSNotification object with the required user info dictionary). However, that would be kind of error-prone and I would consider it a ‘hack’.

    I would recommend that you put your code into a distinct method, call that method from the notification handler from your question, and then use the distinct method for direct calls.

    You would then have:

    - (void) shiftViewUpForKeyboard: (NSNotification*) theNotification;
    {
        NSDictionary* userInfo = theNotification.userInfo;
        keyboardSlideDuration = [[userInfo objectForKey: UIKeyboardAnimationDurationUserInfoKey] floatValue];
        keyboardFrame = [[userInfo objectForKey: UIKeyboardFrameBeginUserInfoKey] CGRectValue];
        [self doSomethingWithSlideDuration:keyboardSlideDuration frame:keyboardFrame];
    }
    

    Implement the doSomethingWithSlideDuration:frame: method as an instance method of your class. In the code where you call it directly, call doSomethingWithSlideDuration:frame instead of calling the notification handler.

    You need to pass the slide duration and frame on your own when calling the method directly.

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

Sidebar

Related Questions

I have this method in my db class public function query($queryString) { if (!$this->_connected)
I have written this clone method for when the parent of the Employee class
I have an abstract class with some methods,including an abstract method(Execute()).This method is overridden
In my base class I have a generic method (ideally this would be a
I have problem with Android using the class HttpUrlConnection my method is this: public
I have a method on my generated partial class like this: var pChildren =
I have a class with a method called DataIn(int InputID, string CSVValue) , this
I have a proxied method in a MongoRepository extender class like this: public interface
I have a Cocoa/Objective-C class with a method that looks something like this: -
I have a class extends NamedParameterJdbcDaoSupport. well this superclass has a final setDataSource method

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.