这是一个说明问题的片段。当手机处于横向状态时,按钮的顶角不可见。怎么会?这是一个持续发生在我身上的问题。
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIViewAutoresizing ar = UIViewAutoresizingFlexibleWidth|UIViewAutoresizingFlexibleHeight;
window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[window makeKeyAndVisible];
window.rootViewController = self; //The delegate is a controller
UIViewController* vc = [[UIViewController new] autorelease];
nc = [[UINavigationController alloc] initWithRootViewController:vc];
CGRect r = self.view.frame;
r.origin = CGPointZero;
nc.view.frame = r;
[self.view addSubview:nc.view];
nc.view.autoresizingMask = ar;
UIView* b = [UIButton buttonWithType:UIButtonTypeRoundedRect];
r.size = vc.view.frame.size;
b.frame = r;
b.autoresizingMask = ar;
[vc.view addSubview:b];
return YES;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
return YES;
}
感谢。
答案 0 :(得分:0)
我今天也遇到了这样的问题 - 尝试将调整大小掩码设置为所有可用的标志:
UIViewAutoresizingFlexibleHeight |
UIViewAutoresizingFlexibleWidth |
UIViewAutoresizingFlexibleRightMargin |
UIViewAutoresizingFlexibleBottomMargin |
UIViewAutoresizingFlexibleTopMargin |
UIViewAutoresizingFlexibleLeftMargin ;