Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/156.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
Ios webView应该在一个程序中运行,但可以';我不能让它在别的地方工作_Ios - Fatal编程技术网

Ios webView应该在一个程序中运行,但可以';我不能让它在别的地方工作

Ios webView应该在一个程序中运行,但可以';我不能让它在别的地方工作,ios,Ios,我已经在我的一个程序中非常成功地使用了shouldStartLoadWithRequest,但是整个项目都是概念验证,而且很粗糙,我现在重新开始一个新项目 但是,shouldstartoadwithrequest不再为我调用,但是我看不出这两个项目之间的重要区别在哪里(但是有一个区别是第一个是使用.nibs,第二个我没有使用它们) 为了开始工作,我使用了一个控制器,其视图为UIWebView: @interface IMSRootController : UIViewController <

我已经在我的一个程序中非常成功地使用了
shouldStartLoadWithRequest
,但是整个项目都是概念验证,而且很粗糙,我现在重新开始一个新项目

但是,
shouldstartoadwithrequest
不再为我调用,但是我看不出这两个项目之间的重要区别在哪里(但是有一个区别是第一个是使用.nibs,第二个我没有使用它们)

为了开始工作,我使用了一个控制器,其视图为UIWebView:

@interface IMSRootController : UIViewController <UIWebViewDelegate> {

    UIWebView*  webView;
}
怎么了


谢谢

您的对象未被设置为
UIWebView
对象的委托,因此您将不会收到任何委托消息。在某些情况下,无论是在
loadView
中,还是在
displayPage
中(但在调用
loadHTMLString:baseURL:
之前),都要执行以下操作:


我有一个类似的问题,我已经设置了委托,并且正在调用webViewDidFinishLoad和webViewDidStartLoad方法,但是当我单击链接时,不会调用shouldStartLoadWithRequest??如果您正在调用
webViewDidStartLoad
webViewDidFinishLoad
,然后还应该调用
webView:shouldStartLoadWithRequest:navigationType:
。仔细检查委托方法实现是否定义正确(
-(BOOL)webView:(UIWebView*)webView shouldStartLoadWithRequest:(NSURLRequest*)请求导航类型:(UIWebViewNavigationType)navigationType
)这就是问题所在,尽管从定义复制,但我的方法定义不正确。我没想到事情会这么简单。干杯!很高兴听到事情就这么简单。
- (void)loadView {
    [super loadView];
    webView = [[UIWebView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];
    self.view = webView;
    [webView release]; }


- (void)viewDidLoad {
    [super viewDidLoad];
    [[self navigationController] setNavigationBarHidden:YES animated:NO];
    [self displayPage]; }

-(void) displayPage { ...   [webView loadHTMLString:self.htmlString baseURL:baseURL]; }


- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType 
{
...
webView.delegate = self;