1
我最近注意到我的应用程序中有一个非常奇怪的行为。为视图设置框架时,它的行为就像是我输入的原点的两倍。没有其他视图受到影响,受影响视图的宽度和高度也不受影响。有人看过或听说过这样的事情吗?iPad像素倍增?
编辑:
这是我的自定义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;
}
你可以张贴一些代码? – 2011-02-03 03:39:20
我在发布一些代码后更新了我的答案。 – 2011-02-03 18:09:25