ActionSheetViewController.h
#import <UIKit/UIKit.h> @interface ActionSheet2ViewController : UIViewController{ } -(IBAction)popupAction:(id)sender; @end
ActionSheetViewController.m
#import "ActionSheet2ViewController.h" @implementation ActionSheet2ViewController -(IBAction)popupAction:(id)sender{ UIActionSheet *popupMessage = [[UIActionSheet alloc] initWithTitle:@"Select Search Site" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"google", @"yahoo", @"bing", nil]; [popupMessage showInView:self.view]; [popupMessage release]; } -(void)actionSheet:(UIActionSheet *)popupAction clickedButtonAtIndex:(NSInteger)buttonIndex{ if(buttonIndex ==0){ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.google.com/"]]; }else if(buttonIndex == 1){ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.yahoo.com/"]]; }else if(buttonIndex == 2){ [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.bing.com/"]]; } } - (void)didReceiveMemoryWarning { // Releases the view if it doesn't have a superview. [super didReceiveMemoryWarning]; // Release any cached data, images, etc that aren't in use. } - (void)viewDidUnload { // Release any retained subviews of the main view. // e.g. self.myOutlet = nil; } - (void)dealloc { [super dealloc]; } @end
参考
YouTube - iOS SDK Tutorial -- Programming a UIActionSheet using Case statementshttp://www.youtube.com/watch?v=QiVzDeXR0F0&hd=1
0 件のコメント:
コメントを投稿