見出しが述べているように。私は2つのストーリーボードを持っています。1つはiPhone用、もう1つはiPad用です。iPhoneは機能しますが、iPadは機能しません。ボタンにアクセスできます。たとえば、iPadとiOSではsetTitleを実行できますが、insertSublayerを実行すると、これはiPhoneでのみ機能します。
理由は何でしょうか?
みんなありがとう!
編集:
UIColor *color1 = [UIColor colorWithRed:(228/255.0) green:(91/255.0) blue:(0/255.0) alpha:(1.0)];
UIColor *color2 = [UIColor colorWithRed:(152/255.0) green:(61/255.0) blue:(0/255.0) alpha:(1.0)];
NSNumber *stopOne = [NSNumber numberWithFloat:0.0];
NSNumber *stopTwo = [NSNumber numberWithFloat:1.0];
NSArray *locations = [NSArray arrayWithObjects:stopOne, stopTwo, nil];
CAGradientLayer *buttonALayer = [CAGradientLayer layer];
buttonALayer.frame = startGame.layer.bounds;
float iOSversion = [[UIDevice currentDevice].systemVersion floatValue];
int layerIndex = 1;
if (iOSversion < 5.9)
{
layerIndex = 0;
}
float cornerRadius = 0.0f;
buttonALayer.colors = colorsA;
buttonALayer.locations = locations;
buttonALayer.cornerRadius = cornerRadius;
[startGame.layer insertSublayer:buttonALayer atIndex:layerIndex];
<-このコードはiPhoneでは機能しますが、iPadでは機能しません。次のコードは両方のデバイスで機能します(シミュレーター!):
[startGame setTitle:@"Bullwaste" forState: UIControlStateNormal];
<-iPadでも動作するので、私にとってはアウトレットとリファレンスが理由ではないように思われますか?
編集2:
私は次のことをしようとしました:
startGame.alpha = 0.3;
NSString *justAString = [NSString stringWithFormat: @"%f", startGame.bounds.size.width];
[startGame setTitle:justAString forState: UIControlStateNormal];
iPhone Simでの反応:ボタンが透明になり、タイトルが280.0000になりますiPad Simでの反応:ボタンが透明になり、タイトルが0.00000になります
分かりませんか?startGame.alphaは機能しますstartGame.bounds.size.widthはiPhoneでのみ機能します!?!?