Ios_5_ Tom Cat

Source: Internet
Author: User

Eventually:

BeyondViewController.h

  beyondviewcontroller.h//  05_tomcat////  Created by Beyond on 14-7-23.//  Copyright (c) 2014 Com.beyond. All rights reserved.//#import <UIKit/UIKit.h> @interface Beyondviewcontroller: Uiviewcontroller@property (Weak, nonatomic) Iboutlet Uiimageview *imgview_tom;-(ibaction) BtnClick: (UIButton *) sender ; @end


Beyondviewcontroller.m

beyondviewcontroller.m//05_tomcat////Created by Beyond on 14-7-23.//Copyright (c) 2014 Com.beyond. All rights reserved.//#import "BeyondViewController.h" @interface Beyondviewcontroller () {nsdictionary *_dict;}    @end @implementation beyondviewcontroller-(void) viewdidload{[Super Viewdidload];    Sg_bundle template code, 1, gets the. App main package, 2, returns the FullPath full path of a file in the main package nsbundle *mainbundle = [NSBundle mainbundle];    NSString *fullpath = [Mainbundle pathforresource:@ "Tom.plist" oftype:nil];    _dict = [Nsdictionary Dictionarywithcontentsoffile:fullpath];    }-(ibaction) Btnclick: (UIButton *) Sender {//If being animated, return directly if ([_imgview_tom isanimating]) {return;    }//button above the text is the dictionary key, the corresponding value-1 is the corresponding animation picture number//NSString *text = Sender.titleLabel.text;    NSString *text = [Sender titleforstate:uicontrolstatenormal];    int *picnum = [_dict[text] intvalue];        NSLog (@ "%@----%d", text,picnum);    Call the custom method to play the animation [self playanimatitonnamed:text picnumber:picnum]; }-(VOID) playanimatitonnamed: (NSString *) name Picnumber: (int) picnum{//Instantiate variable group Nsmutablearray *array = [Nsmutablearray ar    Ray]; Add uiimage for (int i=0; i<picnum; i++) to a mutable array {//Generate image Mode 1, memory-resident, heavy pressure, real chance to collapse nsstring *fullname = [N        Sstring stringwithformat:@ "%@_%02d.jpg", name,i];        UIImage *img = [UIImage imagenamed:fullname]; Generate image mode 2,io Read full path, run out, do not reside memory//nsstring *fullpath = [[NSBundle mainbundle] Pathforresource:fullname oftype:nil        ];        UIImage *IMG2 = [[UIImage alloc] initwithcontentsoffile:fullpath];    Add UIImage to array [array addobject:img];    }//Set Uiimageview animation parameters and submit animation _imgview_tom.animationimages = array;    _imgview_tom.animationduration = 0.1*picnum;    _imgview_tom.animationrepeatcount = 1; [_imgview_tom startanimating];} @end














Ios_5_ Tom Cat

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.