【发布时间】:2011-08-24 12:11:27
【问题描述】:
我想在一个 XIB 中切换两个视图,但我不想为此使用 UINavigationController,因为它的效率非常低,因为只需要发生一个转换。这是我的代码:
// 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];
// set up an animation for the transition between the views
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromLeft];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[theWindow addSubview:webViewTwo];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
.h
@class WebViewTwo;
@interface SecondViewController : UIViewController {
IBOutlet WebViewTwo *webViewTwo;
}
现在它因错误而崩溃
2011-05-12 16:59:59.528 TableView[36627:207] -[WebViewTwo superview]: unrecognized selector sent to instance 0x603b660
2011-05-12 16:59:59.531 TableView[36627:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[WebViewTwo superview]: unrecognized selector sent to instance 0x603b660'
请帮忙!谢谢。
【问题讨论】:
标签: objective-c cocoa-touch xcode ios4 uinavigationcontroller