模拟UINavigation推送问题?

发布于 2024-11-06 11:49:14 字数 1283 浏览 0 评论 0原文

我在一个 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'

请帮忙!谢谢。

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 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我偏爱纯白色 2024-11-13 11:49:14

该错误往往表明 WebViewTwo 不是 UIView 的子类,或者之前已发布并且不再指向 UIView< 子类的对象/代码>。检查定义 WebViewTwo 的头文件,也许在将其添加为子视图之前添加 NSLog(@"%@", webViewTwo); 以查看它是什么类型。

希望这有帮助。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文