2010-09-16 46 views
1

獲得一個視圖邊界矩形,而在橫向模式下返回錯誤的大小:iPhone風景模式返回不正確的觀點尺寸

(我知道有過很多景觀模式的帖子,但沒有在這個問題上)

從一個新的UIView模板項目開始,我加入單一的UIView到ViewController在界面生成器(在風景模式)和設置視圖尺寸與寬度= 400,高度= 200;但是,當我在ViewController中添加一個斷點時,代碼如下: - (void)viewDidAppear:(BOOL)animated {CGI} viewRect = [testView bounds]; } 尺寸是w = 220,h = 380! (即使觀點顯然是正確的在屏幕上)

在myViewController.m我設置:

- (BOOL)shouldAutorotateToInterfaceOrientation: 
(UIInterfaceOrientation)interfaceOrientation { 
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight); // home button on right 
} 

在myAppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
application.statusBarOrientation = UIInterfaceOrientationLandscapeRight; //home on right 
    [window addSubview:viewController.view]; 
    [window makeKeyAndVisible]; 
    return YES; 
} 

,並在info.plist中我設置了:初始界面方向=風景(右側主頁按鈕)

我是不是試圖旋轉vie w與iPhone一起使用,意味着僅在Landscape中進行修復。

是否有解決方法?我需要根據正確的視圖大小創建一些CALayers。

感謝

史蒂夫

回答

1

聽起來像一個狀態欄相關的問題。這就是說我沒有很好的解決方案。

除了看框架,你可以看看界限。有時這會提供更好的信息。

+1

感謝您的答覆。原來我對主視圖controller.Sounds明顯的「自動調整子視圖」,但因爲沒有大小調整正在發生,我不知道爲什麼這應該有所作爲,但它的治癒它。 – Steve555 2010-09-17 07:20:19