iOS Development--Summary & Common Development Summary

Source: Internet
Author: User

First, notice
1. Monitoring Notifications

    • -(void) Addobserver: (ID) Observer selector: (SEL) aselector name: (NSString *) AName object: (ID) anobject;
    • The Aselector method of observer is called when the AnObject object publishes a notification named Aname


2. Release Notifications

    • Publish a Notification object (name, object, UserInfo)
    • -(void) Postnotification: (nsnotification *) notification;
    • AnObject released a notice named Aname.
    • -(void) Postnotificationname: (NSString *) AName object: (ID) anobject;
    • AnObject released a notification named Aname, and passed an extra data: Auserinfo
    • -(void) Postnotificationname: (NSString *) AName object: (ID) anobject userInfo: (nsdictionary *) Auserinfo;


Second, load the controller from the storyboard inside
1. Load Storyboard

    • 1> Method 1: Use the name of the storyboard file
    • + (Uistoryboard *) Storyboardwithname: (NSString *) name Bundle: (NSBundle *) Storyboardbundleornil;
    • 2> Method 2: Storyboard method of the Controller
    • -[Uiviewcontroller Storyboard]


2. Loading the Controller

    • Returns the first controller (initialization controller, the controller that the Arrow refers to)
    • -(ID) Instantiateinitialviewcontroller;
    • Returns a controller that uniquely identifies the identifier
    • -(ID) Instantiateviewcontrollerwithidentifier: (NSString *) identifier;


Third, block definition format
Definition of 1.block variables

    • void (^myblock) (int, int);
    • Myblock = ^ (int a, int b) {
    • };


int age = 10;

[e-mail protected] Definition

    • @property (nonatomic, copy) void (^myblock) (int, int);
    • @property (nonatomic, assign) int age;


3. Parameters as Methods

    • -(void) Setmyblock: (void (^) (int, int)) Myblock;
    • -(void) Setage: (int) age;


Iv. Common functions of CGRect

    • 1.CGRectGetMinX (CGRect rect) functions such as

    • 2.CGRectContainsPoint (< #CGRect Rect#>, < #CGPoint point#>)


Five, the cutting of uiimage

    • Cgimagecreatewithimageinrect (< #CGImageRef Image#>, < #CGRect rect#>)


VI, anti-aliasing

    • -(void) Clearalias
    • {
    • Self.layer.borderWidth = 2;
    • Self.layer.borderColor = [Uicolor Clearcolor]. Cgcolor;
    • The layer will be rendered as a bitmap.
    • Self.layer.shouldRasterize = YES;
    • For (UIView *child in self.subviews) {
    • [Child Clearalias];
    • }
    • }


Seven, timer
1.NSTimer

    • 1> artificially controlled refresh rate
    • 2> low refresh rate, suitable for slow refresh
    • 3> Creating a Timer
    • Returns a new timer, but does not start the timer and needs to call the fire method
    • + (Nstimer *) Timerwithtimeinterval: (nstimeinterval) TI target: (ID) atarget selector: (SEL) Aselector userInfo: (ID) UserInfo repeats: (BOOL) Yesorno;
    • Return a new timer and start the timer immediately
    • + (Nstimer *) Scheduledtimerwithtimeinterval: (nstimeinterval) TI target: (ID) atarget selector: (SEL) Aselector UserInfo :(ID) UserInfo repeats: (BOOL) Yesorno;
    • 4> Stop timer (as long as the timer stops, you cannot start the timer again)
    • -(void) invalidate;


2.CADisplayLink

    • 1> contains quartzcore frames
    • 2> Fixed refresh frequency (1 seconds Refresh 60 times)
    • 3> requires high refresh speed, suitable for fast refresh
    • 4> Creating DisplayLink
    • Returns an Cadisplaylink timer object that will call 60 times the target's Sel method in 1 seconds and pass Cadisplaylink as a parameter
    • + (Cadisplaylink *) Displaylinkwithtarget: (ID) Target selector: (SEL) sel;
    • 5> Start Timing
    • -(void) Addtorunloop: (Nsrunloop *) Runloop Formode: (NSString *) mode;
    • 6> Stop Timing
    • -(void) invalidate;
    • 7> Brush Frame Interval
    • @property (readonly, nonatomic) cftimeinterval duration;
    • 8> control Pause or continue
    • @property (getter=ispaused, nonatomic) BOOL paused;


Eight, animation
Animations in 1.UIView Packages

    • 1> end-to-end
    • [UIView Beginanimations:nil Context:nil];
    • // ... What animations need to be performed
    • [UIView commitanimations];


2> Block

    • [UIView animatewithduration:0.5 animations:^{
    • Animations that need to be performed
    • } completion:^ (BOOL finished) {
    • Animation complete
    • }];


3> Transition Animation (transition animation)

    • Make a view perform a transition animation
    • [UIView transitionwithview:<# (UIView *) #> duration:<# (nstimeinterval) #> options:<# ( uiviewanimationoptions) #> animations:<#^ (void) animations#> completion:<#^ (BOOL finished) completion# >];


Animation of 2.CALayer

    • What values can the keypath of cabasicanimation and cakeyframeanimation be?
    • Search in Xcode documents: Calayer animatable Properties
    • Specific properties of transform: Search Catransform3d Key Path

1> cabasicanimation

    • * Fromvalue Initial value
    • * Tovalue final value (from initialization change to last value)
    • * Byvalue Step value (based on initial value, how many values are added)


2> cakeyframeanimation

    • * Values


3> catransition (Transition animation)

    • Catransition *anim = [catransition animation];
    • Anim.type = @ "Cube";
    • Anim.subtype = Kcatransitionfrombottom;
    • [View.layer Addanimation:anim Forkey:nil];


4> Caanimationgroup

    • * Animation, you can perform multiple animations at the same time


3. How to select an animation

    • 1> If you need to perform multiple animations repeatedly, it's best to choose Calayer animations
    • 2> If the animation is finished, it is necessary to use the previous things, it is best to choose UIView block animation
    • 3> If you need to perform multiple animations at the same time, it's best to choose Caanimationgroup
    • The most flexible of 4> uiview animations and Calayer animations is the Calayer animation


4. Customize some animations

    • Use Cadisplaylink to complete animations that need to be performed in the brush frame method

iOS Development--Summary & Common Development Summary

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.