Programming with iOS8 from scratch [common controls for iOS development] And ios8ios

Source: Internet
Author: User

Programming with iOS8 from scratch [common controls for iOS development] And ios8ios

Master haomeng is devoted to his contribution and respects the author's Labor achievements. Do not repost them.

If the article is helpful to you, you are welcome to donate to the author, support haomeng master, the amount of donation is free, focusing on your mind ^_^

I want to donate: Click to donate

Cocos2d-X source code download: point I send


The AlertView control dialog box is displayed. Modify the HelloHaoMengZhu project code and add the AlertView:
-(IBAction) testAlert {NSString * str = [[NSString alloc] initWithFormat: @ "Hello, % @", txtField. text]; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "prompt" message: str delegate: self cancelButtonTitle: @ "OK" otherButtonTitles: nil]; [str release]; [alert show]; [alert release];}-(void) alertView :( UIAlertView *) alertView didDismissWithButtonIndex :( NSInteger) buttonIndex {NSLog (@ "% @", @ "OK ");}


ActionSheet Control
ActionSheet and AlertView are similar in that they both give users a prompt. It is popped up from the bottom. It is usually used to identify potential dangerous or unrecoverable operations, such as deleting a data.
To use ActionSheet, we need to implement the UIActionSheetDelegate protocol in the H file. Among them, we often need to implement: actionSheet: didDismissWithButtonIndex:
This method is called when the ActionSheet disappears.
Modify the Hello-. h file
@interface HelloHaoMengZhuViewController : UIViewController{    UITextField *txtField;    UIActivityIndicatorView * myActivityView;        IBOutlet UIProgressView *Progress;NSTimer *timer;}
Add the Protocol UIActionSheetDelegate to the Hello_Controller.h file:
-(IBAction) testActionSheet {NSString * str = [[NSString alloc] initWithFormat: @ "Hello, % @", txtField. text]; UIActionSheet * action = [[UIActionSheet alloc] initWithTitle: @ "prompt" delegate: self cancelButtonTitle: @ "cancel" destructiveButtonTitle: @ "OK" otherButtonTitles: nil]; [str release]; [action showInView: self. view]; [action release];}-(void) actionSheet :( UIActionSheet *) actionSheet didDismissWithButtonIndex :( NSInteger) buttonIndex {if (buttonIndex = [actionSheet destructiveButtonIndex]) {NSLog (@ "% @", @ "OK");} else if (buttonIndex = [actionSheet cancelButtonIndex]) {NSLog (@ "% @", @ "cancel ");}}


Wait for controls
For some time-consuming processing, you need to use some wait controls to eliminate the user's waiting time.
Wait for the related controls to include:
UIActivityIndicatorView
UIProgressView
Design UI:

Implementation of UIActivityIndicatorView
-(IBAction)onClickButton2: (id)sender {if ([myActivityView isAnimating]) {[myActivityView stopAnimating];} else {[myActivityView startAnimating];}}


UIProgressView implementation
-(IBAction)start{Progress.progress = 0.0;timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(update) userInfo:nil repeats:YES];}
Code Description:
NSTimer can start a thread implicitly,
ScheduledTimerWithTimeInterval specifies the time when a thread is called to sleep. The selector specifies the update method.
-(Void) update {Progress. progress = Progress. progress + 0.1; if (Progress. progress = 1.0) {[timer invalidate]; UIAlertView * alert = [[UIAlertView alloc] initWithTitle: @ "" message: @ ". avi download complete! "Delegate: self cancelButtonTitle: @" OK "otherButtonTitles: nil]; [alert show]; [alert release];}
Code Description:
The progress attribute of the UIProgressView control is 0.0 ~ 1.0 annoying range. At the starting position at 0.0, the progress reached 1.0 at 100%.


Master haomeng is devoted to his contribution and respects the author's Labor achievements. Do not repost them.

If the article is helpful to you, you are welcome to donate to the author, support haomeng master, the amount of donation is free, focusing on your mind ^_^

I want to donate: Click to donate

Cocos2d-X source code download: point I send


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.