我在我的 AppDelegate 中创建一个数组,然后想在另一个视图控制器中使用它(不断重复,直到我关闭视图)。它填充数组,但似乎没有动画。我已经搜索并进行了几天的编辑。任何帮助,将不胜感激!
AppDelegate.h
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (nonatomic, retain) NSMutableArray *sharedArray1;
@end
AppDelegate.m
#import "Scene1.h"
@synthesize sharedArray1;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
int ii;
for (ii = 1; ii<70;) {
[sharedArray1 addObject:[UIImage imageWithData:[NSData dataWithContentsOfFile:[[NSBundle mainBundle]pathForResource:[NSString stringWithFormat:@"RadarCircle_Active%i.png", ii] ofType:nil]]]];
NSLog(@"Log RadarCircle_Active i: %i",ii);
ii = ii + 1; // increment by 1
}
return YES;
}
场景1.m
#import "AppDelegate.h"
-(void)radarActive{
float duration1 = 5.5;
AppDelegate *appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
activeRadarImage.animationImages = appDelegate.sharedArray1;
activeRadarImage.animationDuration = duration1;
// activeClawImage.animationRepeatCount = count;
[activeRadarImage startAnimating];
}