UIButton with Touch up Inside event
1. In this post you learn how to perform Touch up Inside event on UIButton and also learn UIAlertView for that first create View-base Application and put one UIButton and UITextField from object liberary and change text property of button and
define IBOutlet and IBAction in UIButtonDemoViewController.h file .
#import <UIKit/UIKit.h>
@interface UIButtonDemoViewController : UIViewController
{
IBOutlet UITextField * textField;
}
@property(nonatomic,retain)IBOutlet UITextField * textField;
-(IBAction)getText:(id)sender;
@end
2. Now set IBOutlet and IBAction to your button and text field put your IBOutlet textField small circle round drag on button to UITextField and IBAction getText to button and select Touch Up Inside event.
define IBOutlet and IBAction in UIButtonDemoViewController.h file .
#import <UIKit/UIKit.h>
@interface UIButtonDemoViewController : UIViewController
{
IBOutlet UITextField * textField;
}
@property(nonatomic,retain)IBOutlet UITextField * textField;
-(IBAction)getText:(id)sender;
@end
2. Now set IBOutlet and IBAction to your button and text field put your IBOutlet textField small circle round drag on button to UITextField and IBAction getText to button and select Touch Up Inside event.
3.Now modify UIButtonDemoViewController.m file
#import "UIButtonDemoViewController.h"
@implementation UIButtonDemoViewController
@synthesize textField;
-(IBAction)getText:(id)sender
{
[textField resignFirstResponder];
UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"Text in TextField" message:textField.text delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
- (void)dealloc
{
[textField release];
[super dealloc];
}
4. Now click build and go and touch on button you can see following output
#import "UIButtonDemoViewController.h"
@implementation UIButtonDemoViewController
@synthesize textField;
-(IBAction)getText:(id)sender
{
[textField resignFirstResponder];
UIAlertView * alert=[[UIAlertView alloc]initWithTitle:@"Text in TextField" message:textField.text delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert show];
[alert release];
}
- (void)dealloc
{
[textField release];
[super dealloc];
}
4. Now click build and go and touch on button you can see following output
Releted Posts :
1. UIText Field with default and number pad keybord
2. Animation like a toggle button in iphone
3. UIActionSheet button event in iphone
4. Create combobox using UIActionsheet
5. UISegmented control in iPhone with value change event
6. Create simple UINavigation controller in iPhone
2. Animation like a toggle button in iphone
3. UIActionSheet button event in iphone
4. Create combobox using UIActionsheet
5. UISegmented control in iPhone with value change event
6. Create simple UINavigation controller in iPhone
HTML Comment Box is loading comments...