2012-05-06 27 views
0

這是我的代碼。我可以看到出現小對話框,然後對話框佔據整個屏幕。哪裏不對?iOS UIView as對話框

ChangeProfileImage *changeProfileImage =[[ChangeProfileImage alloc] init]; 

changeProfileImage.modalPresentationStyle = UIModalPresentationFormSheet; 
changeProfileImage.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; 
[self presentModalViewController:changeProfileImage animated:YES]; 
changeProfileImage.view.superview.frame = CGRectMake(0, 0, 200, 200);//it's important to do this after 
changeProfileImage.view.superview.center = self.view.center 
+0

ChangeProfileImage是從哪裏繼承而來的?它有什麼作用? – Caleb

回答

0

我已準備好要告訴你一切的錯誤與此代碼,但後來我成立了一個簡單的iPad的單一視圖的應用程序,並嘗試下面的代碼:

- (IBAction)FlipPressed:(id)sender { 
    UIViewController *vc = [[UIViewController alloc] init]; 
    UIView *view = [vc view]; 
    [view setBackgroundColor:[UIColor redColor]]; 
    [vc setModalPresentationStyle:UIModalPresentationFormSheet]; 
    [vc setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; 
    [self presentModalViewController:vc animated:YES]; 
    [[[vc view] superview] setFrame:CGRectMake(0, 0, 200, 200)]; 
    [[[vc view] superview] setCenter:[[self view] center]]; 
} 

當我嘗試這一點,我得到一個紅色的盒子,200x200,圓角,翻轉到屏幕中央的視圖。

據我所知,我已經非常準確地複製了你的代碼,我想我得到了你想要的結果,對吧?

編輯/ UPDATE

進一步的測試似乎表明當iPad處於縱向這段代碼只會工作。否則,我的觀點似乎是「垂直」翻轉(關於iPad如何定位)並且視圖不居中。

+0

仍然有白色背景顯示紅色框出現,但我當前的視圖也被刪除 – user2514963

+0

根據該評論,這可能是衝擊和支撐(UIAutoResizingMask)的問題。你可以拍攝一張屏幕截圖併發布嗎? – mbm29414