Comments (14)
我明白你的问题了,我这边尝试重现一下吧,或者你可否把一部分代码给我看一下,这个自己写的返回按钮是viewController中的一个类似“退出”的button,不是navigationBar上的backButton是吧~
from rxwebviewcontroller.
是的,就是把navigationBar隐藏,为了达到满足各种效果,自己用UIView模拟的导航栏,点击调用 [self popViewControllerAnimated:YES],这种情况下就会类似多米诺骨牌,pop到rootViewController。我现在可以通过把你写得RxWebViewController的navigationBar隐藏,自己也这样写,暂时可解决这问题。我这有demo,需要的话您告诉我下邮件地址或发我邮件[email protected],我把demo给你。
from rxwebviewcontroller.
[email protected] 最近工作比较忙,抱歉可能不能及时回复,周末我会抽时间解决这个问题!谢谢反馈!!
from rxwebviewcontroller.
应该解决了,问题出在
-(BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item{
if ([self.viewControllers.lastObject class] == [RxWebViewController class]) {
RxWebViewController* webVC = (RxWebViewController*)self.viewControllers.lastObject;
if (webVC.webView.canGoBack) {
[webVC.webView goBack];
//!make sure the back indicator view alpha back to 1
[[self.navigationBar subviews] lastObject].alpha = 1;
return NO;
}else{
[self popViewControllerAnimated:YES];
return YES;
}
}
return YES;
}
这里,如果当前 VC 是RxWebViewController 才应该执行 pop 动作,否则应该交给系统处理
from rxwebviewcontroller.
上面那段代码还是有问题.... 其它页面点击返回 会出现 页面不返回 但是 titile 返回的样子 ...屏蔽掉这段代码.就不会影响其它页面了
from rxwebviewcontroller.
@tanranran 我这边也是,不知你解决了没有
from rxwebviewcontroller.
我也发现这个问题,后来发现作者
用下面这个方法截获系统返回操作时,没有处理不是 RxWebViewController class类的情况。-(BOOL)navigationBar:(UINavigationBar )navigationBar shouldPopItem:(UINavigationItem *)item{
if ([self.viewControllers.lastObject class] == [RxWebViewController class]) {
RxWebViewController webVC = (RxWebViewController*)self.viewControllers.lastObject;
if (webVC.webView.canGoBack) {
[webVC.webView goBack];
//!make sure the back indicator view alpha back to 1
[[self.navigationBar subviews] lastObject].alpha = 1;
return NO;
}else{
[self popViewControllerAnimated:YES];
return YES;
}
}
return YES;
}
即使在其他界面点击返回按钮,这段代码依然会截获到系统的pop事件,但是仔细看,你会发现,当viewController 不是RxWebViewController这个类时,这段代码没有处理,我是这样解决的
-(BOOL)navigationBar:(UINavigationBar )navigationBar shouldPopItem:(UINavigationItem *)item{
if ([self.viewControllers.lastObject class] == [RxWebViewController class]) {
RxWebViewController webVC = (RxWebViewController*)self.viewControllers.lastObject;
if (webVC.webView.canGoBack) {
[webVC.webView goBack];
//!make sure the back indicator view alpha back to 1
[[self.navigationBar subviews] lastObject].alpha = 1;
return NO;
}else{
[self popViewControllerAnimated:YES];
return YES;
}
}
else{
//加上else分句,当不是RxWebViewController,就直接执行pop操作
[self popViewControllerAnimated:YES];
}
return YES;
}
from rxwebviewcontroller.
@MonkeyS914 测试了下您的代码...还是有问题.
from rxwebviewcontroller.
还是你说的那个问题?导航栏返回了,但是页面没返回?我这边测试ok,其他的viewcontroller点击返回正常了
from rxwebviewcontroller.
@MonkeyS914 @tanranran @HHbreak 我更新了代码,放弃了之前的 category
,使用了新的 RxWebViewNavigationViewController
,大家将自己的 navigationController
继承到这个上面,pop 普通页面会产生的问题应该都修复了,大家看一下,有问题随时联系我~ 谢谢!!
from rxwebviewcontroller.
其实你没必要拦截系统的这个返回事件
直接修改这个方法就好
-(void)customBackItemClicked{
if (self.webView.canGoBack) {
[self.webView goBack];
}
else
{
[self.navigationController popViewControllerAnimated:YES];
}
}
from rxwebviewcontroller.
@MonkeyS914 你这里的 customBackItemClicked 方法是自己 subclass RxWebViewController 的时候添加的对吧,用于你自己重写了导航栏的状况是没问题的,但是如果是没有重写,仅仅是用系统提供的导航栏的情况是不是必须要拦截这个事件了呢~ 所以你的这种情况,其实可以把我的 category 或者 NavigationController 部分删掉,然后再加上你的这个方法就没问题了~~
感谢回复和支持~
from rxwebviewcontroller.
这个是你RxWebViewController 写的,我只是改了一下,因为觉得把我自己的navigationcontroller继承到你的那个NavigationController 感觉有点麻烦,于是就直接把demo里面的category删除了,修改了下你的返回的item响应方法。您的的这个效果实现思路很special,学习了,哈哈!
from rxwebviewcontroller.
我也出现了楼上的bug,第一次正常进入web,退出,再次进入,点击返回就依然停留在web页面了.push之前的页面是隐藏了导航栏的,其他页面的导航栏是显示的
from rxwebviewcontroller.
Related Issues (19)
- 使用自己的NavigationController,push的时候会晃动一下 HOT 3
- push一个新页面出来的时候,导航条右边一直闪
- 在真机上面返回无效
- 关于RxWebViewNavigationViewController的返回判断 HOT 1
- 如果使用init初始化 调用js方法失效
- 滑动返回闪现当前页
- 有时候返回按钮会消失,此时还在webview页面,没有退出到原生页面,导致无法退出,这种现象偶尔会出现 HOT 2
- iphone7模拟器无法侧滑返回
- 第二次点击会有左侧快速闪俩下的效果不知道为什么?
- 一年了,项目还是没有更新 HOT 3
- why you do this in viewDidDisappear method
- cocoaPods上版本0.0.2,是不是很久没更新了?
- 项目路径真乱,根本不是拖进来一个文件夹的事 HOT 2
- 当前一个VC设置setNavigationBarHidden为YES的时候,第二次进入webVC的时候,返回有BUG HOT 12
- 内存问题
- 偶尔pop出RxWebViewCotroller的问题 HOT 3
- 二级页面无法右滑返回。 HOT 3
- self.navigationController.navigationBarHidden = YES 的时候 不会触发 -(BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxwebviewcontroller.