2011-02-03 9 views
1

私は最近、私のアプリで非常に奇妙な動作に気づいた。ビューのフレームを設定するとき、原点が入力したものの2倍であるかのように振る舞います。他のビューは影響を受けず、影響を受けるビューの幅と高さもありません。誰かがこれの前にこのような何かを見たり聞いたり?iPadピクセル倍増ですか?

EDIT:

これは何とか問題を引き起こしているように見える私のカスタムのinitメソッド内のコードですが、私は、なぜ離れて選ぶことができません。

if ((self = [super initWithFrame:frame])) { 
     self.backgroundColor = [UIColor clearColor]; 
     self.controller = aController; 
     self.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.0]; 
     UIView *centerView = [[UIView alloc] initWithFrame:frame]; 
     [self addSubview:centerView]; 
     UIToolbar *navBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, 44)]; 
     NSMutableArray *array = [[NSMutableArray alloc] init]; 
     UIBarButtonItem *item = item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemStop target:self action:@selector(closeClicked:)]; 
     [array addObject:item]; 
     item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
     [array addObject:item]; 
     item = [[UIBarButtonItem alloc] initWithTitle:@"Title" style:UIBarButtonItemStylePlain target:nil action:nil]; 
     [array addObject:item]; 
     item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 
     [array addObject:item]; 
     item = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:nil action:nil]; 
     [array addObject:item]; 
     [navBar setItems:array]; 
     [centerView addSubview:navBar]; 
     centerView.clipsToBounds = YES; 
     centerView.opaque = TRUE; 
     centerView.alpha = 1.0; 
     centerView.backgroundColor = [UIColor whiteColor]; 
     [self addSubview:centerView]; 
    } 
    return self; 
} 
+0

? –

+0

いくつかのコードを掲示した後、私の答えを更新しました。 –

答えて

2

私はxibsで前にこのような変わったことを経験しました。これは、通常、xibがiPad xibの代わりにiPhone xibとして内部的にラベル付けされているために発生します。通常は、最初からxibを作り直す必要があります。

普遍的なアプリですか?あなたのiPad xibがあなたのView Controllerがinitされたときに読み込まれているものであることを確認してください。

あなたは、コードを追加した後、EDIT:

問題はあなたが渡しているフレームように見えるあなたのinitメソッドは、(H、W、10,10)のフレームを渡さなっている場合は、。自分のコンテキストが何であっても10,10になることを意味するcenterViewを作成すると、ここに囲まれたビューが10,10であり、centerviewが囲みビュー内の10,10にある場合、centerviewはより広い範囲内の20,20。

あなたはそのX、Yとして0,0であなたのセンタービューを作成したいと思う:あなたはいくつかのコードを投稿することができ

CGRect centerViewFrame = CGRectMake(0, 0, frame.size.width, frame.size.height); 
UIView *centerView = [[UIView alloc] centerViewFrame]; 
+0

うん。それはそれだった。私のコードを30分ほど過ぎた後にこれを見つけました>。<ありがとう! – Jumhyn

関連する問題