問題が発生しています。ツールバーは、iOS7 iphone 5s 実デバイスの前にパディングを追加します。
;
ただし、この問題はシミュレーターや iOS7 iphone 4s デバイスでは見られません。
私の構成は次のとおりです
何が間違っているのか誰でも指摘できますか?前もって感謝します
問題が発生しています。ツールバーは、iOS7 iphone 5s 実デバイスの前にパディングを追加します。
;
ただし、この問題はシミュレーターや iOS7 iphone 4s デバイスでは見られません。
私の構成は次のとおりです
何が間違っているのか誰でも指摘できますか?前もって感謝します
私はこの修正を誇りに思っていませんが、それは私のために修正します:
// in the app delegate class
#define SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
// in the view
- (void)fixToolbarWidth
{
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
{
float adjust = -10.5f;
// self.toolbar is linked to the UIToolbar
self.toolbar.frame = CGRectMake(adjust, 0, [SizeHelper getSizeInOrientation].width-adjust, self.toolbar.frame.size.height);
// self.segmentedControl is linked to the UISegmentedControl
self.segmentedControl.frame = CGRectMake(0, 0, self.toolbar.frame.size.width+(adjust*2), self.segmentedControl.frame.size.height);
}
}
- (void)viewDidLoad
{
[super viewDidLoad];
// fix on first load
[self fixToolbarWidth];
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willAnimateRotationToInterfaceOrientation:toInterfaceOrientation duration:duration];
// resize if they rotate the device
[self fixToolbarWidth];
}
更新された/よりシンプルなバージョン
ツールバーとセグメント化されたコントローラーが .xib ファイルの全幅をスケーリングするように適切に設定されている限り、次の操作を実行できます。viewDidLoad
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"7.0"))
{
// use a different adjustment for iPad vs iPhone/touch
float adjust = (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? -14.0f : -9.0f;
self.toolbar.frame = CGRectMake(adjust, 0, self.toolbar.frame.size.width-adjust, self.toolbar.frame.size.height);
self.segmentedControl.frame = CGRectMake(0, 0, self.segmentedControl.frame.size.width+adjust, self.segmentedControl.frame.size.height);
}
私も同じ問題を抱えています。私がしているのは、セグメント コントロールをツールバーの外に置くことです。それは私のための仕事です。