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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T06:01:17+00:00 2026-06-03T06:01:17+00:00

I have a custom look designed for my textfields on iphone. I decided to

  • 0

I have a custom look designed for my textfields on iphone. I decided to create a class

MYTextField : UIView <UITextFieldDelegate>

I have a method

- (id)initWithPlaceholder:(NSString*)placeholder position:(CGPoint) position

that creates a UITextField with the desired view and look.

The sourcecode is as follows:

- (id)initWithPlaceholder:(NSString*)placeholder position:(CGPoint) position {
    if (self = [super initWithFrame:CGRectMake(position.x, position.y, TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT)]) {
        UITextField *textField = [[[UITextField alloc] initWithFrame:CGRectMake(10, 200, 300, 40)] autorelease];
        textField.borderStyle = UITextBorderStyleRoundedRect;
        textField.font = [UIFont systemFontOfSize:15];
        textField.placeholder = @"enter text";
        textField.autocorrectionType = UITextAutocorrectionTypeNo;
        textField.keyboardType = UIKeyboardTypeDefault;
        textField.returnKeyType = UIReturnKeyDone;
        textField.clearButtonMode = UITextFieldViewModeWhileEditing;
        textField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;    
        [textField setUserInteractionEnabled:YES];
        textField.delegate = self;

        [self addSubview:textField];
    }
    return self;
}

The problem is that, on invoking the method, the UITextField is visible but on tapping on the textfield, the keyboard doesnt show up.

Is there anything I am missing?

PS: I found a couple of similar problems on Stackoverflow, but none of the solutions seem to work for me. 🙁

  • 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-03T06:01:19+00:00Added an answer on June 3, 2026 at 6:01 am

    The issue here could be that the textfields frame doesn’t lie within the frame of the UIView. Why use TEXTFIELD_WIDTH for the self.frame but not for textfield.frame?

    Also, why subclass UIView rather that UITextField?

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

Sidebar

Related Questions

I have custom exceptions in my django project that look like this: class CustomFooError(Exception):
I have a class that extends JButton because the custom look and feel I'm
I created my own MyScrollbarUI class to have a custom scrollbar look in my
I am have a custom CALayer which should look different with respect to different
I have separate javascript files to load custom objects; these objects are designed to
I have designed a custom file format / network message to reduce size as
I would like to create a custom look for a tooltip. <h:outputText value=blarg title=tooltip>
I have a custom UIView that generates some kind of diagram that needs a
I have a custom class set up as a key that has two properties,
I have custom classes that I currently instantiate within App.xaml as resources. I want

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.