I'm working with a WebView. If I place this call in my -awakeFromNib
:
我正在使用WebView。如果我将此调用放在我的-awakeFromNib中:
[myWebView setMainFrameURL:@"http://www.google.com"];
I get the behavior I want. Google's homepage displays in my WebView. But, I need to set the main frame's URL in another method from a mutable array containing NSStrings.
我得到了我想要的行为。 Google的主页显示在我的WebView中。但是,我需要在包含NSStrings的可变数组中以另一种方法设置主框架的URL。
This method call
这个方法调用
[myWebView setMainFrameURL:[mutableArrayContainingNSStrings objectAtIndex:0]];
does not update the WebView. Do I need to tell the WebView to reload? I tried -setNeedsDisplay:YES
and -reload
to no avail.
不更新WebView。我是否需要告诉WebView重新加载?我试过-setNeedsDisplay:YES和-reload无济于事。
3 个解决方案
#1
I figured out the problem. The WebView is an IBOutlet. I was doing the method call that was giving me problems before -awakeFromNib. Moved that one line to -awakeFromNib and it's sorted now. Thanks for the input. +1 to my list of newbie posts.
我解决了这个问题。 WebView是一个IBOutlet。我正在做-awakeFromNib之前给我带来问题的方法调用。将一行移动到-awakeFromNib并立即进行排序。感谢您的投入。 +1到我的新手帖子列表。
#2
Have you tried setting a breakpoint on your action method to check that both myWebView
and [mutableArrayContainingNSStrings objectAtIndex:0]
are pointing to the correct objects?
您是否尝试在操作方法上设置断点以检查myWebView和[mutableArrayContainingNSStrings objectAtIndex:0]是否指向正确的对象?
#3
Several things
(1) I second Marc's comment in making sure that it is pointing at the correct objects
(1)我是Marc的第二个评论,以确保它指向正确的对象
(2) It's been a while since I've dealt with WebKit directly but I know that it's possible you may have strings like "www.google.com" and strings like that won't work, you need "http://www.google.com" which you have in your first call to myWebView. Make sure all of your URL Strings are like this. It's the browser (Safari/Chrome/etc) that expands www.google.com out into http://www.google.com so that you can actually visit the site
(2)我已经有一段时间了,因为我直接处理了WebKit,但我知道你可能有像“www.google.com”这样的字符串,这样的字符串不起作用,你需要“http:// www .google.com“您在第一次调用myWebView时所拥有的。确保所有的URL字符串都是这样的。浏览器(Safari / Chrome /等)将www.google.com扩展到http://www.google.com,以便您可以实际访问该网站
If none of that works show the strings here so I can verify and run tests to see what's going on with the WebView
如果这些都不能在这里显示字符串,那么我可以验证并运行测试以查看WebView发生了什么
#1
I figured out the problem. The WebView is an IBOutlet. I was doing the method call that was giving me problems before -awakeFromNib. Moved that one line to -awakeFromNib and it's sorted now. Thanks for the input. +1 to my list of newbie posts.
我解决了这个问题。 WebView是一个IBOutlet。我正在做-awakeFromNib之前给我带来问题的方法调用。将一行移动到-awakeFromNib并立即进行排序。感谢您的投入。 +1到我的新手帖子列表。
#2
Have you tried setting a breakpoint on your action method to check that both myWebView
and [mutableArrayContainingNSStrings objectAtIndex:0]
are pointing to the correct objects?
您是否尝试在操作方法上设置断点以检查myWebView和[mutableArrayContainingNSStrings objectAtIndex:0]是否指向正确的对象?
#3
Several things
(1) I second Marc's comment in making sure that it is pointing at the correct objects
(1)我是Marc的第二个评论,以确保它指向正确的对象
(2) It's been a while since I've dealt with WebKit directly but I know that it's possible you may have strings like "www.google.com" and strings like that won't work, you need "http://www.google.com" which you have in your first call to myWebView. Make sure all of your URL Strings are like this. It's the browser (Safari/Chrome/etc) that expands www.google.com out into http://www.google.com so that you can actually visit the site
(2)我已经有一段时间了,因为我直接处理了WebKit,但我知道你可能有像“www.google.com”这样的字符串,这样的字符串不起作用,你需要“http:// www .google.com“您在第一次调用myWebView时所拥有的。确保所有的URL字符串都是这样的。浏览器(Safari / Chrome /等)将www.google.com扩展到http://www.google.com,以便您可以实际访问该网站
If none of that works show the strings here so I can verify and run tests to see what's going on with the WebView
如果这些都不能在这里显示字符串,那么我可以验证并运行测试以查看WebView发生了什么