UITextField use in Iphone

This is simple programming where you can see how to put a UITextField in a UIAlertView. This is simple and just a couple lines of code.

This is simple programming where you can see how to put a UITextField in a UIAlertView. This is simple and just a couple lines of code. 

Step 1: Create a new project, using View-base application.

Step 2: We have to added some code in viewcontroller . In viewDidLoad  we calling a UIAlertView and then we are adding the UITextField .

- (void)viewDidLoad {
    [super viewDidLoad];
       
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Enter Your Name "
                         message:@"Hello"
                         delegate:self
                         cancelButtonTitle:@"Cancel"
                         otherButtonTitles:@"OK!", nil];
       
UITextField *TextField = [[UITextField alloc] initWithFrame:CGRectMake(12, 45, 260, 25)];
CGAffineTransform Transform = CGAffineTransformMakeTranslation(0, 60);
        [alert setTransform:Transform];
        [TextField setBackgroundColor:[UIColor whiteColor]];
        [alert addSubview:TextField];
        [alert show];
        [alert release];
}

Step 3: Now you add CoreGraphics.framework in your framework folder.Only shows up in the iPhone SDK frameworks folder, at /Developer/platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/System/Library/Frameworks.

Step 4: Now compile and run your application on the Simulator.

Figure 1: Shows input name using UITextField

WP Greet Box icon
Hello there! If you are new here, you might want to subscribe to the RSS feed for updates on this topic, and free programming tips and tricks and source code            snippets.

Leave a Reply

Security Code:

learn iphone programming

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Our Mobile Training Courses

EDUmobile.ORG offers the following 4 Mobile Training Courses. Our iPhone Training Course is very popular, with over 200 developers in training.

learn iphone programming
© 2010 EDUmobile.ORG