我在使用UIImageView动画时遇到了一些问题.我创建了三个包含图像的NSArray对象,并创建了三个采用UIImageView并为其分配新动画的方法.它第一次调用三种方法中的一种非常有效,但是另一次它会使模拟器和设备崩溃.有任何想法吗?
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
// set the anims
slowAnimation = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image1.jpg"],
[UIImage imageNamed:@"image2.jpg"],
nil];
defaultAnimation = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image3.jpg"],
[UIImage imageNamed:@"image4.jpg"],
nil];
fastAnimation = [NSArray arrayWithObjects:
[UIImage imageNamed:@"image5.jpg"],
[UIImage imageNamed:@"image6.jpg"],
nil];
// load the default speed - this works once, but when applied a second time it crashes the simulator and device
[self setDefaultAnim:myUIImageViewObject];
[super viewDidLoad];
}
// animation switcher
-(void)setSlowAnim:(UIImageView …Run Code Online (Sandbox Code Playgroud) 快速的问题.是否可以更改已定义样式的值?例如:styles.container.backgroundColor?
我得到了"尝试写入readonly属性"错误,但这似乎很疯狂,我无法动态更改背景颜色.我错过了这样做的最佳实践方法吗?
非常感谢,a.