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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:05:48+00:00 2026-06-08T18:05:48+00:00

I am not getting an error now but my delegate is not working. I

  • 0

I am not getting an error now but my delegate is not working. I am making a custom keyboard so i have the UIViewController and a UIView. I want the UIView to call the sendKeyboardShortCut method in the UIViewController. The sendKeyboardShortCut method is not being called. Thank You

//ViewController .h

#import "KeyboardExtension.h"
@interface PageViewController : UIViewController <UITextViewDelegate,sendKeyboardShortCutDelegate> {
   KeyboardExtension *inputAccView;
}
-(void)sendKeyboardShortCut:(NSString*)shortCut;
@property (nonatomic, assign) IBOutlet UITextView *tv;
@end

//ViewController .m

@implementation PageViewController
@synthesize tv;
- (void)viewWillAppear:(BOOL)animated
{
    tv.delegate = self;
}
-(void)createInputAccessoryView{
    inputAccView = [[[KeyboardExtension alloc] init]autorelease];
    inputAccView.delegate = self;
    NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"KeyboardExtension" owner:self options:nil];
   inputAccView = [nibObjects objectAtIndex:0];
}
-(void)textViewDidBeginEditing:(UITextView *)textView{
    [self createInputAccessoryView];
    [textView setInputAccessoryView:inputAccView];
}


  -(void)sendKeyboardShortCut:(NSString*)shortCut{
    if ([shortCut isEqualToString:@"dash"] ) {

        NSRange range = tv.selectedRange;
        if((range.location+range.length)<=tv.text.length)
        {
            NSString * before = [tv.text substringToIndex:range.location];
            NSString * after = [tv.text substringFromIndex:range.location+range.length];
            tv.text = [NSString stringWithFormat:@"%@-%@",before,after];
        }


    }
}

@end

//keyboard view .h

#import <UIKit/UIKit.h>
@protocol sendKeyboardShortCutDelegate <NSObject>
-(void)sendKeyboardShortCut:(NSString*)shortCut;
@end
@interface KeyboardExtension : UIView
-(IBAction)dash:(id)sender;
@property(nonatomic,assign) id<sendKeyboardShortCutDelegate>delegate;
@end

//keyboard view .m

#import "KeyboardExtension.h"

@implementation KeyboardExtension
@synthesize delegate;
-(IBAction)dash:(id)sender{[delegate sendKeyboardShortCut:@"dash"];}
@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-08T18:05:51+00:00Added an answer on June 8, 2026 at 6:05 pm

    I suspect that:

    1) your button’s target is the nib’s file owner and not KeyboardExtension

    2) your action is setup not to send the sender, so UIKit calls -comma instead of -comma:

    Also, the following code is highly suspect:

    inputAccView = [[[KeyboardExtension alloc] init]autorelease];
    inputAccView.delegate = self;
    NSArray *nibObjects = [[NSBundle mainBundle] loadNibNamed:@"KeyboardExtension" owner:self options:nil];
    inputAccView = [nibObjects objectAtIndex:0];
    

    A) you allocate an object that you barely use as you replace it immediately with the nib’s object

    B) the way to extract the object from the nib ([nibObjects objectAtIndex:0]) is really not robust. You should create an IBOutlet in PageViewController and link it in the nib

    I think you should revisit the way you use nibs here.

    A final (unrelated) point: why are you using [NSString stringWithFormat:@"..."] instead of just @"..."?

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

Sidebar

Related Questions

I have been scratching my head since long now but not getting around to
I have recently updated my gitorious instance and I’m getting an error now. Error
I have declared my two dimensional array like this. But getting an error due
edit i am not getting the error undefined index 'time' any longer. Now i
I have used this code to send mails but I am not getting any
I am not getting any error message in browser due to curly brace missing
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition
Not sure why I'm getting this error and can't figure it out? The cycle
I am getting the error: 'string[]' does not contain a definition for 'Cast' and
I'm getting the error T does not contain a definition for Id below in

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.