Home > Tutorials Home > Ios > UIButton Example in iOS

UIButton Example in iOS

Published on October 17, 2019 7:57:14 PM


This Application helps you to create a Button Example

Step 1 : Open the XCode and create a new Single View Based Application template. Give the application name "Button Example". Copy this Code to the ViewController.h and hook up the properties with appropriate control.
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *txtName;
- (IBAction)displayAlert:(id)sender;
Step 2 : Copy the Following Code into your ViewController.m File.
#import "ViewController.h"
@implementation ViewController
@synthesize txtName;
- (IBAction)displayAlert:(id)sender
	UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"System Message" message:[NSString stringWithFormat:@"Welcome, %@",[txtName text]] delegate:nil cancelButtonTitle:@"Okey" otherButtonTitles:nil, nil];
    [alert show];

UIButton Example in iOS - Video Tutorial