私のアプリを iPhone 5 と以前の小さい iPhone の両方で動作させるのに苦労しています。iOS6 を要求して Autolayout を使用すると、うまく機能します。
ただし、アプリには定期的に位置を入れ替える 4 つのボタンがあるため、配列から各ボタンに異なる位置を割り当ててから、次のような方法で動きをアニメートします。
[UIView animateWithDuration:0.5 animations:^{
button1.center = [[locations objectAtIndex:0] CGPointValue];
button2.center = [[locations objectAtIndex:1] CGPointValue];
button3.center = [[locations objectAtIndex:2] CGPointValue];
button4.center = [[locations objectAtIndex:3] CGPointValue];
}];
これは Autolayout では機能しません。何も変わりません。私が得た最高のものは、位置にアニメーション化され、すぐに元に戻ることです.
ただし、Autolayout を削除すると、小さな iPhone ではすべてのボタンが押しつぶされ、iPhone 5 のサイズで設定されたポイントを使用しているため、下の行が画面から外れてしまいます。私は元々、Interface Builder から取得した異なる CGPoint 番号を持っていましたが、Autolayout が使用する番号だったので「間違っていた」と思っていましたが、それらは「間違っていた」ものでした。あなたが見ることができるように配列:
buttonLocations = [NSArray arrayWithObjects:
[NSValue valueWithCGPoint:CGPointMake(57, 523)],
[NSValue valueWithCGPoint:CGPointMake(109, 523)],
[NSValue valueWithCGPoint:CGPointMake(57, 471)],
[NSValue valueWithCGPoint:CGPointMake(109, 471)],
nil];
この問題を解決するにはどうすればよいですか? サイズの異なるデバイスごとに異なるポイントを設定することは、あまり効率的ではないようです。