DOC PREVIEW
SDSU CS 696 - Segment Control, Alerts & Action Sheets

This preview shows page 1-2-3-18-19-37-38-39 out of 39 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 39 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS 696 Mobile Application DevelopmentFall Semester, 2010Doc 8 Segment Control, Alerts & Action SheetsSep 23, 2010Copyright ©, All rights reserved. 2010 SDSU & Roger Whitney, 5500 Campanile Drive, San Diego, CA 92182-7700 USA. OpenContent (http://www.opencontent.org/openpub/) license defines the copyright on this document.References2iPhone Human Interface Guideline, http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/MobileHIG/Introduction/Introduction.htmlVarious UI class documentationBeginning iPhone 3 Development: Exploring the iPhone SDK by Jeff LaMarche, and David Mark, Chapter 4iPad31024 by 768 pixelsiOS 3.2iPhone views & controls workAddedSplit viewsPopoversToolbars top or bottomCan replace keyboard with custom inputCreating Project4Targeted Device5iPhone/ipad universal binaryiPhone runs on ipad Uses iPhone screeniPad does not run on iPhoneSegment Control6groups number of controls togetherUIView7Container for viewsSubclass it for custom contentWhen view is hidden all views it contains are hiddenNested Views8UIView with blue backgroundContains LabelSliderUIView with red backgroundContains2 labels2 switchesBlue UIView (top level)Connections9@interface SegmentControlViewController : UIViewController { }@property (nonatomic, retain) IBOutlet UIView * blueView;@property (nonatomic, retain) IBOutlet UIView * redView;- (IBAction) toggleColor: (id) sender;@endOutletsblueViewredViewActionstoggleColor:SegmentControlViewController10#import "SegmentControlViewController.h"#define RED_INDEX 0#define BLUE_INDEX 1@implementation SegmentControlViewController@synthesize blueView;@synthesize redView;SegmentControlViewController11- (IBAction) toggleColor: (id) sender { switch ([sender selectedSegmentIndex]) { case RED_INDEX: [self showRed]; break; case BLUE_INDEX: [self showBlue]; break; default: [self hideBlueRed]; break; }}SegmentControlViewController12- (void) showRed { blueView.hidden = YES; redView.hidden = NO;}- (void) showBlue { //blue is the top view inside of red blueView.hidden = NO; redView.hidden = NO;}- (void) hideBlueRed { //blue is the top view inside of red //blue is hidden when red is redView.hidden = YES;}SegmentControlViewController13- (void) dealloc { [blueView release]; [redView release];}Options14bar with red tintborderedbarplainbezeledPropertiessegmentedControlStyle tintColorMomentary15Linking actions in code16- (void)viewDidLoad { [super viewDidLoad]; [colorSelector addTarget:self action:@selector(toggleColor:) forControlEvents:UIControlEventValueChanged];}@property (nonatomic, retain) IBOutlet UISegmentedControl * colorSelector;Alert & Action Sheets17Alerts & Actionsheets18modal - user has to dismiss themAlertGives information about problem or changeAction sheetGives additional choices related to current actionThe Connections19@interface AlertActionSheetViewController : UIViewController <UIActionSheetDelegate, UIAlertViewDelegate>{ }- (IBAction) showAlert;- (IBAction) showActionSheet;@endActionsshowActionSheetshowAlertCreating the ActionSheet20- (IBAction) showActionSheet { UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Are you sure?" delegate:self cancelButtonTitle:@"No Way!" destructiveButtonTitle:@"Yes, I'm Sure!" otherButtonTitles:@"Foo",@"Bar",nil]; actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque; [actionSheet showInView:self.view]; [actionSheet release];}Responding to users selection21- (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger)buttonIndex { NSLog(@"action"); if (buttonIndex == [actionSheet cancelButtonIndex]){ NSLog(@"cancelled"); return; } NSLog(@"User selected %@", [actionSheet buttonTitleAtIndex:buttonIndex]);}Showing the alert22- (IBAction) showAlert { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"This is an alert" message: @"Hi mom" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"A",@"B",nil]; [alert show]; [alert release];}Responding to the Alert23- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == [alertView cancelButtonIndex]){ NSLog(@"cancelled"); return; } NSLog(@"User selected %@", [alertView buttonTitleAtIndex:buttonIndex]);}Alert Operations24 delegate property title property message property visible property – addButtonWithTitle: numberOfButtons property – buttonTitleAtIndex: cancelButtonIndex property firstOtherButtonIndex property – show – dismissWithClickedButtonIndex:animated:UIAlertViewDelegate Protocol25Responding to Actions – alertView:clickedButtonAtIndex:Customizing Behavior – willPresentAlertView: – didPresentAlertView: – alertView:willDismissWithButtonIndex: – alertView:didDismissWithButtonIndex:Canceling – alertViewCancel:Alert & Background process26iOS 3When application is terminated alerts are closed automaticallyiOS 4When application move to background or terminated alerts not closed automaticallyYour code has to decide when to close alertBut how?App Delegate Methods27- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions - (void)applicationWillResignActive:(UIApplication *)application - (void)applicationDidBecomeActive:(UIApplication *)application - (void)applicationWillTerminate:(UIApplication *)application - (void)applicationDidReceiveMemoryWarning:(UIApplication *)applicationSimplistic Solution28- (void)applicationWillResignActive:(UIApplication *)application { [viewController movingToBackground];}AlertActionSheetAppDelegateAlertActionSheetViewController- (void) movingToBackground { [sampleAlert dismissWithClickedButtonIndex:[sampleAlert cancelButtonIndex] animated:YES];}Designing An Alert - title29Single line titlesUse sentence fragmentsAvoid single word titlesError, WarningAvoid using"you", "your", "me", "my"Designing An Alert - title30Use Title-Style Capitalization And No PunctuationTitle is a sentence fragmentTitle is single sentence & not questionUse sentence-style capitalization ending with "?" for questionUse question if it replaces additional messageUse sentence-style capitalization & ending punctuation for complete


View Full Document

SDSU CS 696 - Segment Control, Alerts & Action Sheets

Download Segment Control, Alerts & Action Sheets
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Segment Control, Alerts & Action Sheets and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Segment Control, Alerts & Action Sheets 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?