UIActionSheet button event in iPhone and how to update base number.
Here you learn UIActionSheet button event when you click on UIActionSheet button Log can be display which button is pressed
by user.
by user.
1.Simply create View Base application and drag on UIButton in UIActionSheetDemo.xib file and change title to click and open
UIActionSheetDemo.h file and define IBAction.
#import <UIKit/UIKit.h>
@interface UIActionSheetDemo : UIViewController <UIActionSheetDelegate>
{
}
-(IBAction)removeAll:(id)sender;
@end
2.Now set open your UIActionSheetDemo.xib file and control drag from button to File's Owner and ser action removeAll and
modify your UIActionSheetDemo.m file as following and build and run your project.
@implementation AlertsProgressViewController
-(IBAction)removeAll:(id)sender
{
UIActionSheet * myActionSheet=[[UIActionSheet alloc]initWithTitle:@"Remove All?" delegate:self
cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:@"Not Sure?", nil];
[myActionSheet showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"Button Index : %i",buttonIndex);
if (buttonIndex==[actionSheet cancelButtonIndex])
{
[UIApplication sharedApplication].applicationIconBadgeNumber=[UIApplication sharedApplication].applicationIconBadgeNumber-1;
}
else if(buttonIndex==0)
{
[UIApplication sharedApplication].applicationIconBadgeNumber=[UIApplication
sharedApplication].applicationIconBadgeNumber+1;
}
else
{
[UIApplication sharedApplication].applicationIconBadgeNumber=[UIApplication
sharedApplication].applicationIconBadgeNumber+0;
}
}
- (void)dealloc
{
[super dealloc];
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"Button Index %i",buttonIndex);
}
@end
UIActionSheetDemo.h file and define IBAction.
#import <UIKit/UIKit.h>
@interface UIActionSheetDemo : UIViewController <UIActionSheetDelegate>
{
}
-(IBAction)removeAll:(id)sender;
@end
2.Now set open your UIActionSheetDemo.xib file and control drag from button to File's Owner and ser action removeAll and
modify your UIActionSheetDemo.m file as following and build and run your project.
@implementation AlertsProgressViewController
-(IBAction)removeAll:(id)sender
{
UIActionSheet * myActionSheet=[[UIActionSheet alloc]initWithTitle:@"Remove All?" delegate:self
cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:@"Not Sure?", nil];
[myActionSheet showInView:self.view];
}
-(void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"Button Index : %i",buttonIndex);
if (buttonIndex==[actionSheet cancelButtonIndex])
{
[UIApplication sharedApplication].applicationIconBadgeNumber=[UIApplication sharedApplication].applicationIconBadgeNumber-1;
}
else if(buttonIndex==0)
{
[UIApplication sharedApplication].applicationIconBadgeNumber=[UIApplication
sharedApplication].applicationIconBadgeNumber+1;
}
else
{
[UIApplication sharedApplication].applicationIconBadgeNumber=[UIApplication
sharedApplication].applicationIconBadgeNumber+0;
}
}
- (void)dealloc
{
[super dealloc];
}
#pragma mark - View lifecycle
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
NSLog(@"Button Index %i",buttonIndex);
}
@end
Output when UIActionSheet button taped in simulator
Releted Posts :
1. UIText Field with default and number pad keybord
2. UIActionSheet button event in iphone
3. Create combobox using UIActionsheet
4. UISegmented control in iPhone with value change event
5. Create simple UINavigation controller in iPhone
6. HelloWord with Step by step guide
2. UIActionSheet button event in iphone
3. Create combobox using UIActionsheet
4. UISegmented control in iPhone with value change event
5. Create simple UINavigation controller in iPhone
6. HelloWord with Step by step guide
HTML Comment Box is loading comments...