iOSでアニメーションを作成しようとしていますが、実際の例をコピーしました(私にとってはうまくいきました)が、アニメーションを長くするために編集しました:ボタンを押してアニメーションを開始すると、最初の画像が表示されますが、最初の画像に進むことはありません休み。
以下の私のコードを見てください!
#import "ViewController.h"
#import <QuartzCore/QuartzCore.h>
@interface ViewController ()
@end
@implementation ViewController
@synthesize imageView;
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIImage *image = [UIImage imageNamed:@"invasive0001.png"];
self.imageView =[[UIImageView alloc] initWithFrame:CGRectMake(22, 110, 724, 451)];
[self.view insertSubview : self.imageView atIndex:0];
self.imageView.layer.cornerRadius = 9.0;
imageView.layer.masksToBounds = YES;
imageView.layer.borderColor = [UIColor blackColor].CGColor;
imageView.layer.borderWidth = 3.0;
self.imageView.animationImages = [[NSArray alloc] initWithObjects: [UIImage imageNamed:@"invasive0001.png"],
[UIImage imageNamed:@"invasive0002.png"],//1
[UIImage imageNamed:@"invasive0003.png"],//2
[UIImage imageNamed:@"invasive0004.png"],//3
[UIImage imageNamed:@"invasive0005.png"],//4
[UIImage imageNamed:@"invasive0006.png"],//5
[UIImage imageNamed:@"invasive0007.png"],//6
[UIImage imageNamed:@"invasive0008.png"],//7
[UIImage imageNamed:@"invasive0009.png"],//8
[UIImage imageNamed:@"invasive00010.png"],//9
[UIImage imageNamed:@"invasive0011.png"],//10
[UIImage imageNamed:@"invasive0012.png"],//11
[UIImage imageNamed:@"invasive0013.png"],//12
[UIImage imageNamed:@"invasive0014.png"],//13
[UIImage imageNamed:@"invasive0015.png"],//14
[UIImage imageNamed:@"invasive0016.png"],//15
[UIImage imageNamed:@"invasive0017.png"],//16
[UIImage imageNamed:@"invasive0018.png"],//17
[UIImage imageNamed:@"invasive0019.png"],//18
[UIImage imageNamed:@"invasive0020.png"],//19
[UIImage imageNamed:@"invasive0021.png"],//19
[UIImage imageNamed:@"invasive0022.png"],//20
[UIImage imageNamed:@"invasive0023.png"],//1
[UIImage imageNamed:@"invasive0024.png"],//2
[UIImage imageNamed:@"invasive0025.png"],//3
[UIImage imageNamed:@"invasive0026.png"],//4
[UIImage imageNamed:@"invasive0027.png"],//5
[UIImage imageNamed:@"invasive0028.png"],//6
[UIImage imageNamed:@"invasive0029.png"],//7
[UIImage imageNamed:@"invasive0030.png"],//8
[UIImage imageNamed:@"invasive0031.png"],//9
[UIImage imageNamed:@"invasive0032.png"],//10
[UIImage imageNamed:@"invasive0033.png"],//11
[UIImage imageNamed:@"invasive0034.png"],//12
[UIImage imageNamed:@"invasive0035.png"],//13
[UIImage imageNamed:@"invasive0036.png"],//14
[UIImage imageNamed:@"invasive0037.png"],//15
[UIImage imageNamed:@"invasive0038.png"],//16
[UIImage imageNamed:@"invasive0039.png"],//17
[UIImage imageNamed:@"invasive0040.png"],//18
[UIImage imageNamed:@"invasive0041.png"],//19
[UIImage imageNamed:@"invasive0042.png"],//20
[UIImage imageNamed:@"invasive0043.png"],//1
[UIImage imageNamed:@"invasive0044.png"],//2
[UIImage imageNamed:@"invasive0045.png"],//3
[UIImage imageNamed:@"invasive0046.png"],//4
[UIImage imageNamed:@"invasive0047.png"],//5
[UIImage imageNamed:@"invasive0048.png"],//6
[UIImage imageNamed:@"invasive0049.png"],//7
[UIImage imageNamed:@"invasive0050.png"],//8
[UIImage imageNamed:@"invasive0051.png"],//9
[UIImage imageNamed:@"invasive0052.png"],//10
[UIImage imageNamed:@"invasive0053.png"],//11
[UIImage imageNamed:@"invasive0054.png"],//12
[UIImage imageNamed:@"invasive0055.png"],//13
[UIImage imageNamed:@"invasive0056.png"],//14
[UIImage imageNamed:@"invasive0057.png"],//15
[UIImage imageNamed:@"invasive0058.png"],//16
[UIImage imageNamed:@"invasive0059.png"],//17
[UIImage imageNamed:@"invasive0060.png"],//18
[UIImage imageNamed:@"invasive0061.png"],//9
[UIImage imageNamed:@"invasive0062.png"],//10
[UIImage imageNamed:@"invasive0063.png"],//11
[UIImage imageNamed:@"invasive0064.png"],//12
[UIImage imageNamed:@"invasive0065.png"],//13
[UIImage imageNamed:@"invasive0066.png"],//14
[UIImage imageNamed:@"invasive0067.png"],//15
[UIImage imageNamed:@"invasive0068.png"],//16
[UIImage imageNamed:@"invasive0069.png"],//17
[UIImage imageNamed:@"invasive0070.png"],//19
[UIImage imageNamed:@"invasive0071.png"],//20
[UIImage imageNamed:@"invasive0072.png"],//1
[UIImage imageNamed:@"invasive0073.png"],//2
[UIImage imageNamed:@"invasive0074.png"],//3
[UIImage imageNamed:@"invasive0075.png"],//4
[UIImage imageNamed:@"invasive0076.png"],//5
[UIImage imageNamed:@"invasive0077.png"],//6
[UIImage imageNamed:@"invasive0078.png"],//7
[UIImage imageNamed:@"invasive0079.png"],//8
[UIImage imageNamed:@"invasive0080.png"],//9
[UIImage imageNamed:@"invasive0081.png"],//10
[UIImage imageNamed:@"invasive0082.png"],//11
[UIImage imageNamed:@"invasive0083.png"],//12
[UIImage imageNamed:@"invasive0084.png"],//13
[UIImage imageNamed:@"invasive0085.png"],//14
[UIImage imageNamed:@"invasive0086.png"],//15
[UIImage imageNamed:@"invasive0087.png"],//16
[UIImage imageNamed:@"invasive0088.png"],//17
[UIImage imageNamed:@"invasive0089.png"],//18
[UIImage imageNamed:@"invasive0090.png"],//19
[UIImage imageNamed:@"invasive0091.png"],//20
[UIImage imageNamed:@"invasive0092.png"],//1
[UIImage imageNamed:@"invasive0093.png"],//2
[UIImage imageNamed:@"invasive0094.png"],//3
[UIImage imageNamed:@"invasive0095.png"],//4
[UIImage imageNamed:@"invasive0096.png"],//5
[UIImage imageNamed:@"invasive0097.png"],//6
[UIImage imageNamed:@"invasive0098.png"],//7
[UIImage imageNamed:@"invasive0099.png"],//8
[UIImage imageNamed:@"invasive0100.png"],//9
[UIImage imageNamed:@"invasive0101.png"],
[UIImage imageNamed:@"invasive0102.png"],//1
[UIImage imageNamed:@"invasive0103.png"],//2
[UIImage imageNamed:@"invasive0104.png"],//3
[UIImage imageNamed:@"invasive0105.png"],//4
[UIImage imageNamed:@"invasive0106.png"],//5
[UIImage imageNamed:@"invasive0107.png"],//6
[UIImage imageNamed:@"invasive0108.png"],//7
[UIImage imageNamed:@"invasive0109.png"],//8
[UIImage imageNamed:@"invasive0110.png"],//9
[UIImage imageNamed:@"invasive0111.png"],//10
[UIImage imageNamed:@"invasive0112.png"],//11
[UIImage imageNamed:@"invasive0113.png"],//12
[UIImage imageNamed:@"invasive0114.png"],//13
[UIImage imageNamed:@"invasive0115.png"],//14
[UIImage imageNamed:@"invasive0116.png"],//15
[UIImage imageNamed:@"invasive0117.png"],//16
[UIImage imageNamed:@"invasive0118.png"],//17
[UIImage imageNamed:@"invasive0119.png"],//18
[UIImage imageNamed:@"invasive0120.png"],//19
[UIImage imageNamed:@"invasive0121.png"],//19
[UIImage imageNamed:@"invasive0122.png"],//20
[UIImage imageNamed:@"invasive0123.png"],//1
[UIImage imageNamed:@"invasive0124.png"],//2
[UIImage imageNamed:@"invasive0125.png"],//3
[UIImage imageNamed:@"invasive0126.png"],//4
[UIImage imageNamed:@"invasive0127.png"],//5
[UIImage imageNamed:@"invasive0128.png"],//6
[UIImage imageNamed:@"invasive0129.png"],//7
[UIImage imageNamed:@"invasive0130.png"],//8
[UIImage imageNamed:@"invasive0131.png"],//9
[UIImage imageNamed:@"invasive0132.png"],//10
[UIImage imageNamed:@"invasive0133.png"],//11
[UIImage imageNamed:@"invasive0134.png"],//12
[UIImage imageNamed:@"invasive0135.png"],//13
[UIImage imageNamed:@"invasive0136.png"],//14
[UIImage imageNamed:@"invasive0137.png"],//15
[UIImage imageNamed:@"invasive0138.png"],//16
[UIImage imageNamed:@"invasive0139.png"],//17
[UIImage imageNamed:@"invasive0140.png"],//18
[UIImage imageNamed:@"invasive0141.png"],//19
[UIImage imageNamed:@"invasive0142.png"],//20
[UIImage imageNamed:@"invasive0143.png"],//1
[UIImage imageNamed:@"invasive0144.png"],//2
[UIImage imageNamed:@"invasive0145.png"],//3
[UIImage imageNamed:@"invasive0146.png"],//4
[UIImage imageNamed:@"invasive0147.png"],//5
[UIImage imageNamed:@"invasive0148.png"],//6
[UIImage imageNamed:@"invasive0149.png"],//7
[UIImage imageNamed:@"invasive0150.png"],//8
[UIImage imageNamed:@"invasive0151.png"],//9
[UIImage imageNamed:@"invasive0152.png"],//10
[UIImage imageNamed:@"invasive0153.png"],//11
[UIImage imageNamed:@"invasive0154.png"],//12
[UIImage imageNamed:@"invasive0155.png"],//13
[UIImage imageNamed:@"invasive0156.png"],//14
[UIImage imageNamed:@"invasive0157.png"],//15
[UIImage imageNamed:@"invasive0158.png"],//16
[UIImage imageNamed:@"invasive0159.png"],//17
[UIImage imageNamed:@"invasive0160.png"],//18
[UIImage imageNamed:@"invasive0161.png"],//9
[UIImage imageNamed:@"invasive0162.png"],//10
[UIImage imageNamed:@"invasive0163.png"],//11
[UIImage imageNamed:@"invasive0164.png"],//12
[UIImage imageNamed:@"invasive0165.png"],//13
[UIImage imageNamed:@"invasive0166.png"],//14
[UIImage imageNamed:@"invasive0167.png"],//15
[UIImage imageNamed:@"invasive0168.png"],//16
[UIImage imageNamed:@"invasive0169.png"],//17
[UIImage imageNamed:@"invasive0170.png"],//19
[UIImage imageNamed:@"invasive0171.png"],//20
[UIImage imageNamed:@"invasive0172.png"],//1
[UIImage imageNamed:@"invasive0173.png"],//2
[UIImage imageNamed:@"invasive0174.png"],//3
[UIImage imageNamed:@"invasive0175.png"],//4
[UIImage imageNamed:@"invasive0176.png"],//5
[UIImage imageNamed:@"invasive0177.png"],//6
[UIImage imageNamed:@"invasive0178.png"],//7
[UIImage imageNamed:@"invasive0179.png"],//8
[UIImage imageNamed:@"invasive0180.png"],//9
[UIImage imageNamed:@"invasive0181.png"],//10
[UIImage imageNamed:@"invasive0182.png"],//11
[UIImage imageNamed:@"invasive0183.png"],//12
[UIImage imageNamed:@"invasive0184.png"],//13
[UIImage imageNamed:@"invasive0185.png"],//14
[UIImage imageNamed:@"invasive0186.png"],//15
[UIImage imageNamed:@"invasive0187.png"],//16
[UIImage imageNamed:@"invasive0188.png"],//17
[UIImage imageNamed:@"invasive0189.png"],//18
[UIImage imageNamed:@"invasive0190.png"],//19
[UIImage imageNamed:@"invasive0191.png"],//20
[UIImage imageNamed:@"invasive0192.png"],//1
[UIImage imageNamed:@"invasive0193.png"],//2
[UIImage imageNamed:@"invasive0194.png"],//3
[UIImage imageNamed:@"invasive0195.png"],//4
[UIImage imageNamed:@"invasive0196.png"],//5
[UIImage imageNamed:@"invasive0197.png"],//6
[UIImage imageNamed:@"invasive0198.png"],//7
[UIImage imageNamed:@"invasive0199.png"],//8
[UIImage imageNamed:@"invasive0200.png"],//9
[UIImage imageNamed:@"invasive0201.png"],
[UIImage imageNamed:@"invasive0202.png"],//1
[UIImage imageNamed:@"invasive0203.png"],//2
[UIImage imageNamed:@"invasive0204.png"],//3
[UIImage imageNamed:@"invasive0205.png"],//4
[UIImage imageNamed:@"invasive0206.png"],//5
[UIImage imageNamed:@"invasive0207.png"],//6
[UIImage imageNamed:@"invasive0208.png"],//7
[UIImage imageNamed:@"invasive0209.png"],//8
[UIImage imageNamed:@"invasive0210.png"],//9
[UIImage imageNamed:@"invasive0211.png"],//10
[UIImage imageNamed:@"invasive0212.png"],//11
[UIImage imageNamed:@"invasive0213.png"],//12
[UIImage imageNamed:@"invasive0214.png"],//13
[UIImage imageNamed:@"invasive0215.png"],//14
[UIImage imageNamed:@"invasive0216.png"],//15
[UIImage imageNamed:@"invasive0217.png"],//16
[UIImage imageNamed:@"invasive0218.png"],//17
[UIImage imageNamed:@"invasive0219.png"],//18
[UIImage imageNamed:@"invasive0220.png"],//19
[UIImage imageNamed:@"invasive0221.png"],//19
[UIImage imageNamed:@"invasive0222.png"],//20
[UIImage imageNamed:@"invasive0223.png"],//1
[UIImage imageNamed:@"invasive0224.png"],//2
[UIImage imageNamed:@"invasive0225.png"],//3
[UIImage imageNamed:@"invasive0226.png"],//4
[UIImage imageNamed:@"invasive0227.png"],//5
[UIImage imageNamed:@"invasive0228.png"],//6
[UIImage imageNamed:@"invasive0229.png"],//7
[UIImage imageNamed:@"invasive0230.png"],//8
[UIImage imageNamed:@"invasive0231.png"],//9
[UIImage imageNamed:@"invasive0232.png"],//10
[UIImage imageNamed:@"invasive0233.png"],//11
[UIImage imageNamed:@"invasive0234.png"],//12
[UIImage imageNamed:@"invasive0235.png"],//13
[UIImage imageNamed:@"invasive0236.png"],//14
[UIImage imageNamed:@"invasive0237.png"],//15
[UIImage imageNamed:@"invasive0238.png"],//16
[UIImage imageNamed:@"invasive0239.png"],//17
[UIImage imageNamed:@"invasive0240.png"],//18
[UIImage imageNamed:@"invasive0241.png"],//19
[UIImage imageNamed:@"invasive0242.png"],//20
[UIImage imageNamed:@"invasive0243.png"],//1
[UIImage imageNamed:@"invasive0244.png"],//2
[UIImage imageNamed:@"invasive0245.png"],//3
[UIImage imageNamed:@"invasive0246.png"],//4
[UIImage imageNamed:@"invasive0247.png"],//5
[UIImage imageNamed:@"invasive0248.png"],//6
[UIImage imageNamed:@"invasive0249.png"],//7
[UIImage imageNamed:@"invasive0250.png"],//8
[UIImage imageNamed:@"invasive0251.png"],//9
[UIImage imageNamed:@"invasive0252.png"],//10
[UIImage imageNamed:@"invasive0253.png"],//11
[UIImage imageNamed:@"invasive0254.png"],//12
[UIImage imageNamed:@"invasive0255.png"],//13
[UIImage imageNamed:@"invasive0256.png"],//14
[UIImage imageNamed:@"invasive0257.png"],//15
[UIImage imageNamed:@"invasive0258.png"],//16
[UIImage imageNamed:@"invasive0259.png"],//17
[UIImage imageNamed:@"invasive0260.png"],//18
[UIImage imageNamed:@"invasive0261.png"],//9
[UIImage imageNamed:@"invasive0262.png"],//10
[UIImage imageNamed:@"invasive0263.png"],//11
[UIImage imageNamed:@"invasive0264.png"],//12
[UIImage imageNamed:@"invasive0265.png"],//13
[UIImage imageNamed:@"invasive0266.png"],//14
[UIImage imageNamed:@"invasive0267.png"],//15
[UIImage imageNamed:@"invasive0268.png"],//16
[UIImage imageNamed:@"invasive0269.png"],//17
[UIImage imageNamed:@"invasive0270.png"],//19
[UIImage imageNamed:@"invasive0271.png"],//20
[UIImage imageNamed:@"invasive0272.png"],//1
[UIImage imageNamed:@"invasive0273.png"],//2
[UIImage imageNamed:@"invasive0274.png"],//3
[UIImage imageNamed:@"invasive0275.png"],//4
[UIImage imageNamed:@"invasive0276.png"],//5
[UIImage imageNamed:@"invasive0277.png"],//6
[UIImage imageNamed:@"invasive0278.png"],//7
[UIImage imageNamed:@"invasive0279.png"],//8
[UIImage imageNamed:@"invasive0280.png"],//9
[UIImage imageNamed:@"invasive0281.png"],//10
[UIImage imageNamed:@"invasive0282.png"],//11
[UIImage imageNamed:@"invasive0283.png"],//12
[UIImage imageNamed:@"invasive0284.png"],//13
[UIImage imageNamed:@"invasive0285.png"],//14
[UIImage imageNamed:@"invasive0286.png"],//15
[UIImage imageNamed:@"invasive0287.png"],//16
nil];
//1.5
self.imageView.animationDuration = 30.0;
self.imageView.animationRepeatCount=0;
}
//button to press to start animation
-(IBAction)buttonStart:(id)sender{
[imageView startAnimating];
}
皆さんありがとう!
* *更新: デバイスで実行してみましたが、再生ボタンを押すとクラッシュします。エミュレーターでは問題なく動作します。これは画像が多すぎるためでしょうか?
再度、感謝します。