IOS learning and ios learning routes

Source: Internet
Author: User

IOS learning and ios learning routes

Ideas:

1. Create a singleton

+ (instancetype)shareManager {    static CCPaomaView *pModel = nil;    static dispatch_once_t once;    dispatch_once(&once, ^{        pModel = [[CCPaomaView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, 0.0468 *KScreenHeight)];    });    return pModel;}

2. Store the received data in a local plist, which is not applicable to a large amount of data. Each time the first data is read, the entire plist is read and deleted, and the remaining data is resaved to the plist.

3. Listen to the animation execution end based on the animation proxy and set the animation instance to nil.

-(Void) animationDidStop :( CAAnimation *) anim finished :( BOOL) flag {NSLog (@ "% @", [self. paomaLabel. layer animationForKey: @ "paoMaDeng"]); if ([self. paomaLabel. layer animationForKey: @ "paoMaDeng"] = anim) {// remove the first group of data [_ array removeObjectAtIndex: 0]; // remove the entire plist [CCPaomaModel removePaomaPlist]; // re-write [_ array writeToFile: [CCPaomaModel filename] atomically: YES]; // After the animation is stopped, set the instance to nil _ pmAniamtion = nil; // if (_ array. count> 0) {[self showPaomaView: self. superview];} else {self. hidden = YES; [self removeFromSuperview];} NSLog (@ "% @", self. array );}}

4. Determine whether the animation instance is empty, so that you can switch the interface and run the Trojan to continue, rather than start again.

-(Void) paomaAniamtion :( CGFloat) count {// judge whether the animation instance exists or persists. if (_ pmAniamtion = nil) {_ pmAniamtion = [CABasicAnimation animation]; _ pmAniamtion. keyPath = @ "transform. translation. x "; CGFloat W = CGRectGetWidth (_ paomaLabel. bounds); _ pmAniamtion. fromValue = @ (W); _ pmAniamtion. toValue = @ (-W); _ pmAniamtion. duration = _ aniTime; _ pmAniamtion. repeatCount = count; _ pmAniamtion. removedOnCompletion = NO; // The animation ends without removing _ pmAniamtion. fillMode = kCAFillModeForwards; // The animation ends at the end of the animation. delegate = self; // sets the proxy [_ paomaLabel. layer addAnimation: _ pmAniamtion forKey: @ "paoMaDeng"];} else {_ pmAniamtion. repeatCount = count ;}}

5. Switch the page to pause and resume the animation.

# Pragma mark-the interface appears and disappears, creates, restores, and pauses an animation-(void) viewWillAppear :( BOOL) animated {[_ paomaView showPaomaView: self. view]; [_ paomaView resumeAnimation];}-(void) viewWillDisappear :( BOOL) animated {[_ paomaView pauseAniamtion];}

For more information, see the code on github.

 

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.