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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:19:41+00:00 2026-05-23T07:19:41+00:00

I have subclassed the UIToolbar to make it easier to implement a safari next,

  • 0

I have subclassed the UIToolbar to make it easier to implement a safari next, previous, done sort of thing.
It all worked fine when i was adding it directly (ie not subclassing) but now that i am, it crashes every time i click one of the buttons with
-[keyboardToolBar hideKeyboard:]: unrecognized selector sent to instance
This is the first time i have attempted to subclass something so im not sure if i have done something the wrong way.

Code for the subclass

@interface keyboardToolBar : UIToolbar {
UIToolbar *keyboard;
UIBarItem *previous;
UIBarItem *next;
UIBarItem *done;
}

@property (nonatomic, retain) UIToolbar *keyboard;
@property (nonatomic, retain) UIBarItem *previous;
@property (nonatomic, retain) UIBarItem *next;
@property (nonatomic, retain) UIBarItem *done;

-(void)previousField;
-(void)nextField;
-(void)hideKeyboard;


@end


#import "keyboardToolBar.h"


@implementation keyboardToolBar
@synthesize keyboard, previous, done, next;

-(UIToolbar*)initWithFrame:(CGRect)frame{
//Create a new toolbar
keyboard = [[UIToolbar alloc]initWithFrame:frame];

//Create all the buttons and point them to methods
UIBarButtonItem *previousButton = [[UIBarButtonItem alloc] initWithTitle:@"Previous" 
                                                            style:UIBarButtonItemStyleBordered 
                                                            target:self 
                                                            action:@selector(previousField:)];
UIBarButtonItem *nextButton     = [[UIBarButtonItem alloc] initWithTitle:@"Next" 
                                                            style:UIBarButtonItemStyleBordered 
                                                            target:self 
                                                            action:@selector(nextField:)];
UIBarButtonItem *filler     = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace 
                                                            target:nil 
                                                            action:nil];
UIBarButtonItem *doneButton     = [[UIBarButtonItem alloc] initWithTitle:@"Done" 
                                                            style:UIBarButtonItemStyleBordered 
                                                            target:self 
                                                            action:@selector(hideKeyboard:)];

//Set the width of both of the buttons to make it look pritty
previousButton.width = 70.0f;
nextButton.width = 70.0f;

self.previous = previousButton;
self.next = nextButton;
self.done = doneButton;

//Add the buttons to the toolbar
[keyboard setItems:[[[NSArray alloc] initWithObjects:self.previous, self.next, filler, self.done, nil] autorelease]];


//Release the buttons
[previous release];
[next release];
[filler release];
[done release];


//return the shiny new toolbar
return keyboard;
}

-(void)previousField{

}

-(void)nextField{

}

-(void)hideKeyboard{
NSLog(@"hello");
}


@end

and is called using UIToolbar *keyboard = [[keyboardToolBar alloc] initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, 50)];

I have tried everything i can think of but still get the same error. Im sure i am just not retaining something somewhere of pointing the buttons to the wrong place but any help would be muchly appreciated
Thanks
Darc

  • 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-05-23T07:19:42+00:00Added an answer on May 23, 2026 at 7:19 am

    You (or something you’re doing) is calling hideKeyboard: (note the colon, indicating that the method has one argument.). However, the hideKeyboard method you’ve implemented, doesn’t take any arguments.

    Most likely, hideKeyboard should be changed to:

    - (void)hideKeyboard:(id)sender {
       NSLog(@"hello");
    }
    

    As an aside, the usual style for class names is capitalized, so your subclass should be KeyboardToolBar (and I’d also recommend keeping the same camel case as Apple’s classes, so KeyboardToolbar would be best).

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

Sidebar

Related Questions

I have subclassed UITableViewCell to make a custom cell for a tableView. I add
I have subclassed UIView and provided my own drawRect, which works fine. However I
I have subclassed UIViewController to provide common functionality for all UIViewControllers (for example I'm
I have subclassed Form to include some extra functionality, which boils down to a
I have subclassed java.awt.Frame and have overridden the paint() method as I wish to
I have subclassed Process like so: class EdgeRenderer(Process): def __init__(self,starter,*args,**kwargs): Process.__init__(self,*args,**kwargs) self.starter=starter Then I
I have subclassed a control in C# WinForms, and am custom drawing text in
I have subclassed UIViewController into a new class, PageViewController (I'm writing a simple book
We have subclassed the Silverlight Application class to add some additional functionality and then
I have subclassed UIView object inside a uiscrollview which displays a pdf page. 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.