UIAlertView in Xcode 4.2

Written on:April 8, 2012
Comments are closed

In this video tutorial I am going to explain about UIAlertView using Xcode 4.2.

  • What is UIAlertView
  • How to use UIAlertView
  • Sample Code for UIAlertView in Xcode 4.2
  • How to use IF conditions with UIAlertView

Here is the video tutorial

UIAlertView displays an alert to the user like message box with options like Yes/Cancel or anything you can think of based on what you are trying to achieve.

UIAlertView Sample code

1
2
3
4
5
6
7
8
9
-(void) viewDidLoad{
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Welcome"
				      message:@"This is UIAlertView"
				     delegate:self
                                    cancelButtonTitle:@"Okay"   
                                   otherButtonTitles:@"button 1", @"button 2",nil];    
 
			[alert show];
}

How to use IF conditions with UIAlertView with button index check

 

1
2
3
4
5
6
7
8
9
10
-(void)alertView:(UIAlertView *)actionsheet clickedButtonAtIndex:(NSInteger)buttonIndex{
				if(buttonIndex == 0){
				   UIAlertView *alert1 = [[UIAlertView alloc] initWithTitle:@"Button Index”    
                                       message:@" You clicked button index 0”  
                                       delegate:self
	                               cancelButtonTitle:@"Okay"
				 otherButtonTitles:nil];           
	      [alert1 show];     
}
}

Apple Developer Manual -  [button url='http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAlertView_Class/UIAlertView/UIAlertView.html' size='small' style='blue'] UIAlertView [/button]

Feel free to comment with any improvements for the article.

Thanks,

Abhi

UISlider Example

Written on:June 26, 2013
Comments
are closed

How to use a UISlider in Xcode. You will need 3 IBOutlets. One for the slider and two for the labels. Also you will need one IBAction for the sliders action. In the .m file you need a IBAction and a line to change the value of the label as the slider is moved. Then you need to have two if statements with conditions if it equals 0 to display…

Read more...

Learning Objective C – Integer data type

Written on:August 26, 2011

Here are the topics covered in this tutorial. What is a variable How to declare variables Objective C Data types How to use Int data type in Objective C Match addition sample program Match addition sample program with positive and negative numbers Print results with NSLog. Here is the video for this session Please let me know your feedback. Thanks, Abhishek

Read more...

Simple way of learning Objective C

Written on:August 20, 2011

Here are the topics I will be covering today. Where to find the  Apple SDK How to register for Apple Developer How to install SDK Apple SDK menu links How to launch Xcode Making your first Objective C program How to compile Objective C program What an Objective C error looks like How to find the error Thanks for watching my tutorial.  I have been learning programming on my own. …

Read more...