次のコードに問題があります。
1.) 私が達成しようとしていること; - iOS の AppDelegate でグローバル背景画像または色を表示するには
2.) 何が起きているか; - 表示される画像または色は、エラーや警告が発生していないため、コードが正しく機能していることを示しています。
3.) 問題は何か; - 背景色または画像が画面全体を占めており、それが一番上のレイヤーのようです。そのため、uitext やボタンなどの要素は表示されません。アプリを使用してください!
4.) 私がしたこと; - 以下は、私が使用している appdelegate のコード スニペットです。私はそれがすべての UIViewController と同じように機能することを知っています。私はそれをリファクタリングしようとしているので、1 か所にしかありません。200じゃない!!
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
//Set the background image
if ( IDIOM == IPAD )
{
self.window.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"background.jpg"]];
}
else
{
//Add gradient background
CAGradientLayer *bgLayer = [BackgroundLayer yellowGradient];
bgLayer.frame = self.window.bounds;
[self.window.layer insertSublayer:bgLayer atIndex:0];
}
//This is added so if in-app purchasing is used and the users connections fails in the middle of the transaction it will finalise the payment so it will download or give access to the purchase.
//[ReadingsIAPHelper sharedInstance];
return YES;
}
何か案は?
よろしく、ジェレミー