我想在轉換幻燈片的視圖控制器中切換視圖。我在網上找到了以下代碼。幻燈片UIView轉換
// get the view that's currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view view
UIView *theWindow = [currentView superview];
// remove the current view and replace with myView1
[currentView removeFromSuperview];
[theWindow addSubview:PlayingView];
PlayingView.frame = CGRectMake(0, 0, 320, 460);
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:1];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
這個代碼字很好,但是底部有一個非常惱人的白色條!我發現代碼:
PlayingView.frame = CGRectMake(0, 0, 320, 460);
這似乎不工作。
所以,鏈接到的地方,我發現http://www.iphonedevsdk.com/forum/iphone-sdk-development/13427-uiview-slide-transition.html
我很確定這段代碼不是問題。 – Dair 2011-04-09 00:31:54
@anon你認爲那是什麼? – 2011-04-09 00:33:41