Drag onto window and place as requried
Select and turn on ‘Hide When Stopped’ from it’s properties.
Declare in #ViewController.h
IBOutlet UIActivityIndicatorView *activityIndicator;
In #ViewController.m
//If view could be unloaded//********** VIEW DID UNLOAD **********- (void)viewDidUnload{[super viewDidUnload];[activityIndicator release];activityIndicator = nil;}//********** DEALLOC **********- (void)dealloc{[activityIndicator release];[super dealloc];}To turn on and off[activityIndicator startAnimating];[activityIndicator stopAnimating];
Message Box (Action Sheet) General
Show a main window message box
Alert View will automatically adjust for landscape orientationUIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"The username and password entered are not valid"message:nildelegate:nilcancelButtonTitle:@"OK"otherButtonTitles:nil];[alert autorelease];[alert show];
Show A Message Box
ActionSheet doesn’t auto adjust for landscape orientationUIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"A Message To Display"delegate:nilcancelButtonTitle:@"OK"destructiveButtonTitle:nilotherButtonTitles:nil];[actionSheet showInView:[[self view] window]];[actionSheet autorelease];
OK Cancel Message Box
In your method that want’s to show the action box
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"A Message To Display"delegate:selfcancelButtonTitle:@"Cancel"destructiveButtonTitle:@"OK"otherButtonTitles:nil];[actionSheet showInView:self.view];[actionSheet autorelease];
Add the delegate to the classes @interface
@interface #ViewController_iPhone : UIViewController<UIActionSheetDelegate>{
Add the delegate method
//*******************************************//*******************************************//********** ACTION SHEET DELEGATE **********//*******************************************//*******************************************- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{// the user clicked one of the OK/Cancel buttonsif (buttonIndex == [actionSheet destructiveButtonIndex]){//----- CLICKED OK -----}else if (buttonIndex == [actionSheet cancelButtonIndex]){//----- CLICKED CANCEL -----}}
Multiple Buttons
UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"A Message To Display"delegate:selfcancelButtonTitle:@"Cancel"destructiveButtonTitle:nilotherButtonTitles:@"Test1",@"Test2",nil];[actionSheet showInView:self.view];[actionSheet autorelease];
In
the actionSheet delegate the buttonIndex starts from 0 being the top
most button. If there is a destructiveButtonTitle then this is 0
otherwise it is the first otherButtonTitle.
No comments:
Post a Comment