大家好我一直在尝试开发一个可以在UIImageView中为图像设置动画的cydia,我认为我的代码都很好但是由于某些原因,应用程序每次执行任务时都会崩溃。我已经读到这可能是导致一次加载太多图像的原因,但我只是尝试加载2个小png图像,所以我不认为这可能是原因。请让我知道你的想法!
%hook UISaveToCameraRollActivity
-(void)performActivity {
%orig;
NSBundle *bundle = [[NSBundle alloc] initWithPath:kBundlePath];
NSString *imagePath = [bundle pathForResource:@"hand" ofType:@"png"];
NSString *imagePath1 = [bundle pathForResource:@"floppy" ofType:@"png"];
UIWindow *statusWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen]
bounds]];
statusWindow.windowLevel = UIWindowLevelStatusBar;
statusWindow.hidden = NO;
statusWindow.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.7];
UIImageView *pic = [[UIImageView alloc] initWithFrame:CGRectMake (0, 0, 69, 69)];
pic.animationImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"hand.png"],
[UIImage imageNamed:@"floppy.png"], nil];
pic.animationDuration = 1.0f;
[pic startAnimating];
pic.animationRepeatCount = 0;
[pic release];
pic.center = statusWindow.center;
pic.image = [UIImage imageWithContentsOfFile:imagePath];
pic.image = [UIImage imageWithContentsOfFile:imagePath1];
[statusWindow addSubview:pic];
[statusWindow makeKeyAndVisible];
}
%end
答案 0 :(得分:1)
移动:
[pic release];
到你方法的结尾。一旦释放对象,就不应该与对象进行交互,这几乎是保证应用程序崩溃的有效方法。
如果你不想手动管理内存,你应该试试ARC: