NavigationViewController 与包含 WebView 的视图控制器
我的导航控制器有问题。
首先,有一个navigationviewcontroller。
另外,还有一个包含 webviewcontroller 的视图控制器,这意味着 webview 控制器是在 WEBcontroller.m 内部加载的。
我设置了当加载 WEBcontroller 时,它会自动加载 google.com。该函数位于 -viewDidLoad() 中
,首先,当应用程序启动时,navigationview 加载 WEBcontroller.m,然后 WEBcontroller 按预期加载 google.com。
然后,当我单击 google.com 中的任何链接时,navigationview 会推送一个新视图 [self.navController PushViewController:newWebController 动画:是]; [newWebController gotoUrl:[request.URL AbsoluteString]];
当然,它有效。新加载(和分配)的 WEBController.m 通过调用“gotoUrl”函数加载 gmail.com。
而且,我单击另一个链接转到“gmail.com/help”
所以, 谷歌.com -> gmail.com-> gmail.com/help
然后,我关闭该应用程序,然后玩一些游戏...它可以释放 iPhone 的内存。
再次启动应用程序,将显示“gmail.com/help”网页。然后,我单击导航栏上调用 [popViewController] 的 [后退] 按钮。
然后,导航控制器正确返回到前面显示“gmail.com”页面的 WEBController.m。
但!!有问题。因为内存被 iPhone 'dealloc',所以 WEBController 会再次加载“google.com”页面,而不是“gmail.com”页面。
我已经搜索过这个问题,但我找不到任何答案。
真的感谢您阅读并对我的问题给予一些兴趣。
I have a problem with a navigation controller.
First of all, there is a navigationviewcontroller.
Also, there is A webviewcontroller-containing view controller, meaning that webview controller is loaded inside WEBcontroller.m
I made that when the WEBcontroller is loaded, it automatically loads google.com. The function is in the -viewDidLoad()
First, when the app is launched, navigationview loads WEBcontroller.m, then WEBcontroller loads google.com as intended.
Then, when I click any link in the google.com, navigationview pushes a new view with
[self.navController pushViewController:newWebController animated:YES];
[newWebController gotoUrl:[request.URL absoluteString]];
It, of course, works. The newly loaded(and alloc) WEBController.m loads gmail.com by calling "gotoUrl" function.
And, I click another links to go "gmail.com/help"
So,
google.com -> gmail.com -> gmail.com/help
Then, I close the app, and play some games... it makes iPhone free memory.
Launching the app again, the "gmail.com/help" webpage is shown. Then, I click the [Back] button which is at the navigationBar which calls [popViewController].
Then, the navigation controller properly go back to preceding WEBController.m which was showing "gmail.com" page.
BUT!! there is a problem. Because the memory was 'dealloc' by iPhone, the WEBController is loaded AGAIN with "google.com" page, not "gmail.com" page.
I've searched this problem but I couldn't get any.
Really thank you for reading and giving some interests to my problem.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我很困惑。你正在使用 UIWebView 吗?如果是这样,为什么不让它处理链接/导航呢?为什么要为每次链接点击创建(并推送)一个新的 UIWebView?从技术上讲,视图控制器需要能够处理 IOS 从内存中释放和恢复的情况。这是在 viewDidLoad 和 viewDidUnload 中完成的。但我认为这不是你想要/需要的。
I'm confused. You are using a UIWebView? If so, why don't you just let it handle the links/navigation? Why are you creating (and pushing) a new UIWebView for every link click? Technically speaking, a view controller needs to be able to handle being freed and restored from memory by IOS. This is done in viewDidLoad and viewDidUnload. But I don't think that's what you want/need here.