2012-02-17 26 views
1

下面是一個說明問題的片段。當手機處於橫向模式時,按鈕的頂角不可見。怎麼來的?這是一個不斷髮生在我身上的問題的實例。UINavigationController錯誤大小和錯位包含視圖

- (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

我只是有這樣的問題,今天太 - 試試你的面具調整設置爲所有可用的標誌:

UIViewAutoresizingFlexibleHeight | 
UIViewAutoresizingFlexibleWidth | 
UIViewAutoresizingFlexibleRightMargin | 
UIViewAutoresizingFlexibleBottomMargin | 
UIViewAutoresizingFlexibleTopMargin | 
UIViewAutoresizingFlexibleLeftMargin ; 
+0

沒有幫助,對不起。 – Tiiba 2012-02-22 15:44:45