【问题标题】:Close Child View from Parent从父级关闭子视图
【发布时间】:2011-04-21 02:06:56
【问题描述】:

由于某种原因,当我关闭我的子视图时,它会导致我的 web 视图出现错误(在父视图中)。我用来关闭子视图的调用:(我不知道这是否是正确的做法)

[normalSplashScreen_vc closeNormalSplashScreen];

给我以下错误:

试图从主线程或web线程以外的线程获取web lock。这可能是从辅助线程调用 UIKit 的结果。现在崩溃了...

我不明白为什么关闭子视图会影响底层 web 视图?

(我认为通过调用 closeNormalSplashScreen 函数我正在关闭主视图,即使它是在子视图中调用的 - 如果是这种情况,我该如何解决这个问题?)


主视图

@interface turfplusViewController : UIViewController {
    IBOutlet splashScreen *FirstRunsplashScreen_vc;
    IBOutlet NormalSplashScreen *normalSplashScreen_vc;
    IBOutlet UIWebView *Webview;
}

@property(nonatomic, retain) splashScreen *FirstRunsplashScreen_vc;
@property(nonatomic, retain) NormalSplashScreen *normalSplashScreen_vc;

// Obviously these functions are declared correctly but for the sake of space

 - (void) displayFirstRunSplashScreen { 
    [self presentModalViewController:FirstRunsplashScreen_vc animated:NO];
}

- (void) displayNormalSplashScreen {
    [self presentModalViewController:normalSplashScreen_vc animated:NO];
}

启动画面

两个启动画面基本相同(第一个运行有一个进度条)。

@interface NormalSplashScreen : UIViewController {
    IBOutlet UIActivityIndicatorView *NormalActivityIndicator;
}

@property(nonatomic, retain) UIActivityIndicatorView *NormalActivityIndicator;

// Obviously these functions are declared correctly but for the sake of space

- (void) closeNormalSplashScreen {
    [self dismissModalViewControllerAnimated:YES];
}

thisthis 问题有关。 (第二个没有回答问题……有可能吗?)

【问题讨论】:

    标签: iphone objective-c cocoa-touch memory-management


    【解决方案1】:

    当您从不是主线程的线程执行 UI 操作时,通常会出现此错误。

    你从哪里调用 closeNormalSplashScreen 方法?它是从与主线程不同的线程调用的吗?

    尝试这样做,看看是否仍然出现错误

    [normalSplashScreen_vc performSelectorOnMainThread:@selector(closeNormalSplashScreen) withObject:nil waitUntilDone:YES]; //last argument will change depending on your requirement
    

    【讨论】:

      猜你喜欢
      • 2012-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多