最近、自分のアプリで非常に奇妙な動作をしていることに気付きました。ビューのフレームを設定すると、原点が入力した値の 2 倍であるかのように動作します。他のビューは影響を受けず、影響を受けるビューの幅と高さも影響を受けません。このようなことを以前に見たり聞いたりした人はいますか?
編集:
これは私のカスタム 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;
}