我最近一直在玩 Xcode,却被这个愚蠢的问题困住了。需要帮忙!好的,我在支持文件名 1.jpg、2.jpg...69.jpg 中添加了 69 张图像。它们之所以如此命名,是因为将使用循环通过显示一系列图像来创建动画。这就是我所做的。头文件:
#import <UIKit/UIKit.h>
@interface myBitchViewController : UIViewController{
NSMutableArray *images;
}
@property (retain, nonatomic) NSMutableArray *images;
@end
和实现文件:
#import "myBitchViewController.h"
@implementation myBitchViewController
@synthesize images;
- (void)viewDidLoad {
for (int imagenumber = 1; imagenumber <= 69; imagenumber++) {
NSMutableString *myString = [NSMutableString stringWithFormat:@"%i", imagenumber];
[myString stringByAppendingString:@".jpg"];
[images addObject:[UIImage imageNamed:myString]];
}
CGRect frame = CGRectMake(0.0, 0.0, 320.0, 460.0);
UIImageView *imageview = [[UIImageView alloc] initWithFrame:frame];
imageview.animationImages = images;
imageview.contentMode = UIViewContentModeScaleAspectFit;
imageview.animationDuration = 3;
imageview.animationRepeatCount = 0;
[imageview startAnimating];
[self.view addSubview:imageview];
[imageview release];
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
现在的问题是程序没有抛出任何错误,但是当模拟器运行时它只显示空白的灰色屏幕而不是动画。我哪里错了?