Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone webview委托方法未在后台进程中激发_Iphone_Ios - Fatal编程技术网

Iphone webview委托方法未在后台进程中激发

Iphone webview委托方法未在后台进程中激发,iphone,ios,Iphone,Ios,我正在开发一个应用程序。我正在使用我的静态库。我在后台使用下面的代码运行这个应用程序 -(IBAction)sendKeyValuePair:(id)sender { [NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self withObject:nil]; } -(void)startTheBackgroundJob { NSAutoreleasePool *poo

我正在开发一个应用程序。我正在使用我的静态库。我在后台使用下面的代码运行这个应用程序

   -(IBAction)sendKeyValuePair:(id)sender
  {
    [NSThread detachNewThreadSelector:@selector(startTheBackgroundJob) toTarget:self   withObject:nil];
}
 -(void)startTheBackgroundJob
 {
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

//create the object for library class and do something and release that object.

[pool release];
 }
我创建了一个webview对象,并将该webview添加到我的主类中,如下所示

           web=[[UIWebView alloc]init];
            //web.delegate=self;
            web.frame=CGRectMake(1, 1, 100,100);
            [web loadHTMLString:html_str baseURL:nil];
            [main_View.view addSubview:web];
            [html_str release];
            [web release];
这里我的问题是,如果我将委托设置为self,则应用程序将崩溃。如果我没有设置,则委托方法不会启动。委托方法仅在库类中实现。我想将委托设置为self,并在库类中运行该委托方法。如何执行此操作。

添加此选项

    [web setDelegate:Your library class name instance];

始终在主线程中更新
UI
。或者使用
Grand Central Dispatch
它在后台线程中执行操作显示您管理后台任务,因为当您的应用程序进入后台超过5秒时,所有操作都会停止,直到您的应用程序支持多任务。在5秒之前,只有应用程序崩溃。请注意这一点“这里我的问题是,如果我将委托设置为self,那么应用程序将崩溃”类似于此,应用程序也将崩溃。如果我将委托设置为我的主类并运行,那么主类的委托方法将启动。但我需要实现库类委托方法。