【问题标题】:Simulating UINavigation push issues?模拟 UINavigation 推送问题?
【发布时间】: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


    【解决方案1】:

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

    希望这会有所帮助。

    【讨论】:

    • 它不是 nil 也没有被释放...得到这个:<WebViewTwo: 0x935d8d0>。我在我的 WebViewTwo.h @interface WebViewTwo : UIViewController { 中有这个...如何更改它并将其子类化为 UIView?
    • 开个玩笑。如果其他人有这个问题,只需创建一个 UIView 的 IBOutlet 并将其与您的视图连接并显示它!
    猜你喜欢
    • 2013-08-18
    • 2012-10-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-31
    • 2019-04-05
    • 2019-02-14
    • 1970-01-01
    相关资源
    最近更新 更多