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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:30:42+00:00 2026-06-08T21:30:42+00:00

A few days ago I created a app based on the scroll-view application I

  • 0

A few days ago I created a app based on the scroll-view application I saw on the book Beginning iOS 4 Application Development .The scroll-view will displays smartly when I touch the textfield.
but it always crash when I touch the another textfield.

the debugger display:

2012-07-31 21:32:35.721 View-based Application[1515:c07] -[ViewController keyboardDidShow:]: unrecognized selector sent to instance 0x6a3e400
2012-07-31 21:32:35.723 View-based Application[1515:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[ViewController keyboardDidShow:]: unrecognized selector sent to instance 0x6a3e400'
*** First throw call stack:
(0x14b2022 0xeb2cd6 0x14b3cbd 0x1418ed0 0x1418cb2 0x9d7a29 0x147d855 0x147d778 0x91c19a 0x3ab845 0xbfe1bc4 0x3a6e01 0x4f757 0x45e49 0x45f34 0xbfe5aac 0x1d8ab54 0x3d93509 0x13e9803 0x13e8d84 0x13e8c9b 0x139b7d8 0x139b88a 0x15626 0x2182 0x20f5)
terminate called throwing an exception(lldb) 

I am new to iOS develop.I really don’t know whats wrong. Here is the viewController.m code. Perhaps it is bit long.
Please help me. If someone need the whole code,I can send it to him. My e-mail address:kururuhuang@gmail.com

 #import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize scrollView;


-(void) viewWillAppear:(BOOL)animated{
    //---registers the notifications for keyboard---
    [[NSNotificationCenter defaultCenter]
     addObserver:self 
     selector:@selector(keyboardDidShow:) 
     name:UIKeyboardDidShowNotification 
     object:self.view.window];

    [[NSNotificationCenter defaultCenter]
     addObserver:self 
     selector:@selector(keyBoardDidHide) 
     name:UIKeyboardDidHideNotification 
     object:nil];
}


//---when a TextField view begins editing---
-(void) textFieldDidBeginEditing:(UITextField *)textFieldView{
    currentTextField = textFieldView;
}


//---when the user taps on the return key on the keyboard---
-(BOOL) textFieldShouldReturn:(UITextField *) textFieldView {
    [textFieldView resignFirstResponder];
    return NO;
}

//---when a TextField view is done editing---
-(void) textFieldDidEndEditing:(UITextField *) textFieldView {
    currentTextField = nil;
}

//---when the keyboard appears---
-(void) keyboardDidshow:(NSNotification *) notification {
    if (keyboardIsShown) return;

    NSDictionary* info = [notification userInfo];

    //---obtain the size of the keyboard---
    NSValue *aValue = 
    [info objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [self.view convertRect:[aValue CGRectValue] fromView:nil];

    NSLog(@"%f", [aValue CGRectValue].size.height);

    NSLog(@"%f",keyboardRect.size.height);

    //---resize the scroll view (with keyboard)---
    CGRect viewFrame = [scrollView frame];
    viewFrame.size.height -= keyboardRect.size.height;
    scrollView.frame = viewFrame;

    //---scroll to the current text field---
    CGRect textFieldRect = [currentTextField frame];
    [scrollView scrollRectToVisible:textFieldRect animated:YES];

    keyboardIsShown = YES;
}

//---when the keyboard disappears---
-(void) keyboardDidHide:(NSNotification *) notification {
    NSDictionary* info = [notification userInfo];

    //---obtain the size of the keyboard---
    NSValue* aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
    CGRect keyboardRect = [self.view convertRect:[aValue CGRectValue] fromView:nil];

    //---resize the scroll view back to the orginal size (without keyboard)---
    CGRect viewFrame = [scrollView frame];
    viewFrame.size.height += keyboardRect.size.height;
    scrollView.frame = viewFrame;

    keyboardIsShown = NO;
}

//---before the View window disapppear--
-(void) viewWillDisappear:(BOOL)animated{
    //---removes the notifications for keyboard---
    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                 name:UIKeyboardDidShowNotification
                                                  object:nil];

    [[NSNotificationCenter defaultCenter] removeObserver:self
                                                     name:UIKeyboardWillHideNotification
                                                  object:nil];
}
- (void)viewDidLoad
{
    scrollView.frame = CGRectMake(0,0,320,460);
    [scrollView setContentSize:CGSizeMake(320, 701)];
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}


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

@end
  • 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-08T21:30:43+00:00Added an answer on June 8, 2026 at 9:30 pm

    You appear to have a typo:

    -(void) keyboardDidshow:(NSNotification *) notification {
    

    should be

    -(void) keyboardDidShow:(NSNotification *) notification {
                       ^
    

    Edit

    Thank you @trojanfoe (and @jrturton 11 seconds late :P)
    for pointing out

    -(void) keyboardDidhide:(NSNotification *) notification {
    

    should be

    -(void) keyboardDidHide:(NSNotification *) notification {
                       ^
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A few days ago I set up a small development server. Running on Windows
I am playing with a new website I created a few days ago. The
Few days ago I tried to create a system that jQuery will enable me
I have a project which I created a few days ago as a test
few days ago i asked about how to get all running processes in the
few days ago i read tutorial about GenericRepository and Unit Of Work patterns http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/implementing-the-repository-and-unit-of-work-patterns-in-an-asp-net-mvc-application
A few days ago, I updated my homepage with a new design as shown
A few days ago VS 2010 went in Beta test and usually with new
A few days ago I posted this question and everyone suggested me to use
I few days ago I update my macbook pro to snow leopard, and since

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.