アプリケーションにランダムな背景画像を設定して、誰かがアプリを起動するたびに新しい背景画像が表示されるようにしたいと考えています。
メソッドでこれまでに試したことは次の- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
とおりです。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSMutableArray *myImageNames = [NSMutableArray arrayWithObjects:@"image1.png", @"image2.png", @"image3.png", nil];
int index = arc4random() % [myImageNames count];
UIColor *background = [[UIColor alloc] initWithPatternImage:[myImageNames objectAtIndex:index]];
self.window.backgroundColor = background;
}
エラーは発生しませんが、機能しません...何かアイデアはありますか? :)