我有一個UIPageViewController,其中視圖中添加了兩個子視圖:帶有UITapGestureRecognizer的透明子視圖和帶有一些按鈕的工具欄,當我點擊另一個子視圖時,該按鈕從底部向上滑動。UIPageViewController在旋轉之後將子視圖帶到前面
編輯。 這是子視圖設置在viewDidAppear:(BOOL)動畫
CGRect frame;
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])){
frame = CGRectMake(50, 0, 220, 480);
}
else {
frame = CGRectMake(50, 0, 380, 320);
}
if (!tapView) {
tapView = [[LSTapView alloc]initWithFrame:frame];
//[tapView setBackgroundColor:[UIColor colorWithRed:1 green:0 blue:0 alpha:0.4]];
[self.view addSubview:tapView];
[tapView release];
}
else {
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])){
[tapView setFrame:CGRectMake(50, 0, 220, 480)];
[fontViewController.view setFrame:CGRectMake(0, 480, 320, 92)];
}
else {
[tapView setFrame:CGRectMake(50, 0, 380, 320)];
[fontViewController.view setFrame:CGRectMake(0, 320, 480, 92)];
}
}
if (!fontViewController){
fontViewController = [[LSFontViewController alloc]initWithNibName:@"LSFontView" bundle:nil];
}
if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation])){
[fontViewController.view setFrame:CGRectMake(0, 480, 320, 92)];
}
else {
[fontViewController.view setFrame:CGRectMake(0, 320, 480, 92)];
}
[self.view addSubview:fontViewController.view];
如果我改變頁面,而無需旋轉設備,一切都運行在兩個方向的罰款。然而,當我旋轉設備時,這兩個子視圖消失了,我發現它們不在前面。無論如何,如果我加入這個我的代碼:
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation{
[self.view bringSubviewToFront:tapView];
[self.view bringSubviewToFront:fontViewController.view];
}
一個奇怪的現象發生了:我不能改變的網頁了,或者更好的,一個和下一個viewControllers正確加載,但他們不顯示和網頁別改變。
有人可以解釋我發生了什麼?
謝謝。 L.
你能告訴你如何最初設置你的子視圖? – sergio 2012-08-03 17:16:09
當然,我會編輯問題.. – Lolloz89 2012-08-04 09:18:27