Simulating UINavigation push issues?
I have two views in one XIB I want to switch, but I don't want to use a UINavigationController for this, because it's horribly inefficient because there开发者_StackOverflow中文版 is only one transition that will need to occur. Here's my code:
// 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;
}
Now it's crashing with an error
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'
Please help! Thanks.
The error would tend suggest that either WebViewTwo
is not a subclass of UIView
or has perviously been released and is no longer pointing to an object that is subclass of UIView
. Check the header file where you define WebViewTwo
and perhaps add NSLog(@"%@", webViewTwo);
before you add it as a subview just to see what type it is.
Hope this helps.
精彩评论