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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T10:31:31+00:00 2026-05-29T10:31:31+00:00

I have a UIView subclass that I assign to a text field as follows:

  • 0

I have a UIView subclass that I assign to a text field as follows:

self.textField.inputView = [[HexKeyboard alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];

and this works (i.e., the keyboard comes up). However, how should the HexKeyboard instance know about the textField?

[Of course I can add a property to the HexKeyboard to achieve this (and call it delegate), but I figure there’s a built-in mechanism for this…]

  • 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-29T10:31:32+00:00Added an answer on May 29, 2026 at 10:31 am

    There seems to be no built-in mechanism for this, as the other answerers have pointed out. As Nick says, you don’t need a complex delegate pattern for this. Or rather, you use the delegate pattern, but you get the delegate class for free. In this case it’s the UITextInput protocol.

    So your keyboard probably looks like this (and has a NIB)

    @interface ViewController : UIViewController
    
    // use assign if < iOS 5
    @property (nonatomic, weak) IBOutlet id <UITextInput> *delegate;
    
    @end
    

    When you create the keyboard controller, you assign the UITextInput conformer to it, so something like this:

    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        HexKeyboardController *keyboardController = [[HexKeyboardController alloc] initWithNibName:@"HexKeyboardController" bundle:nil];
        self.textField.inputView = keyboardController.view;
        keyboardController.delegate = self.textField;
    
    }
    

    However, I thought, there MUST be a way to define this keyboard just once and get the keyboard to “automatically know” who the UITextInput object that summoned it is. But I’ve looked around to no avail… you cannot figure out who the firstResponder is unless you troll the view hierarchy yourself or retain your delegates in a list (which would cause a retain loop). Plus, this isn’t so bad because the HexKeyboardController will unload, too, when the textField is dealloced.

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

Sidebar

Related Questions

I have a UIView subclass that draws itself when -drawRect: is called. It only
I want to have a UIView subclass that has a border image, but I
I have a UIView subclass ( CustomView for purposes of this question) that has
So I have a Subclass of UIView that is suppose to detect touches. The
I have a UIView subclass that overrides UIResponder's touchesMoved: message. I've noticed that when
I have the following code in a UIView subclass that will move it off
I have a custom UIView subclass that i'm trying to use as a header
I have a UIScrollView subclass that I am programmatically scrolling using UIView animations. I'd
I created a subclass of UITableViewCell and added two identical UIView s that have
I have a UIView subclass that I am doing some custom drawing in. When

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.