//
// ViewController.m
// day2-11
//
// Created by Yiling Zheng on 20/06/2019.
// Copyright © 2019 Yiling Zheng. All rights reserved.
//
#import "ViewController.h"
@interface ViewController ()
- (IBAction)stand:(id)sender;
- (IBAction)xiaoZhao:(id)sender;
- (IBAction)daZhao:(id)sender;
@property (weak, nonatomic) IBOutlet UIImageView *imageView;
@property (strong,nonatomic)IBOutlet NSMutableArray *standImages;
@property (strong,nonatomic)IBOutlet NSMutableArray *xiaoZhaoImages;
@property (strong,nonatomic)IBOutlet NSMutableArray *daZhaoImages;
@end
@implementation ViewController
//重复代码
- (void)viewDidLoad {
[super viewDidLoad];
self.standImages = [self loadImageWithimagePrefix:@"stand" count:10];
self.xiaoZhaoImages = [self loadImageWithimagePrefix:@"xiaozhao1" count:21];
self.daZhaoImages = [self loadImageWithimagePrefix:@"dazhao" count:86];
[self stand];
}
-(NSArray *)loadImageWithimagePrefix:(NSString*)prefix count:(int)count
{
NSMutableArray<UIImage *> *images= [NSMutableArray array];
for (int i = 0; i < count; i++) {
NSString *imageName = [NSString stringWithFormat:@"%@_%d",prefix,i+1];
UIImage *image = [UIImage imageNamed:imageName];
[images addObject:image];
}
return images;
}
- (IBAction)stand:(id)sender {
self.imageView.animationImages = self.standImages;
self.imageView.animationRepeatCount = 0;
self.imageView.animationDuration = 0.7;
[self.imageView startAnimating];
}
- (IBAction)xiaoZhao:(id)sender {
self.imageView.animationImages = self.xiaoZhaoImages;
self.imageView.animationRepeatCount = 1;
self.imageView.animationDuration = 1;
[self.imageView startAnimating];
//播放完成后再执行站立
//seclctor:方法,onbject:参数,delay时间
}
- (IBAction)daZhao:(id)sender {
self.imageView.animationImages = self.daZhaoImages;
self.imageView.animationRepeatCount = 1;
self.imageView.animationDuration = 3;
[self.imageView startAnimating];
}
@end
为什么已经实现了stand方法留在viewdidload方法中,通过[self stand]方法时,依然提示“No visible @interface for 'ViewController' declares the selector 'stand'”??