GithubHelp home page GithubHelp logo

Comments (14)

Roxasora avatar Roxasora commented on July 3, 2024

我明白你的问题了,我这边尝试重现一下吧,或者你可否把一部分代码给我看一下,这个自己写的返回按钮是viewController中的一个类似“退出”的button,不是navigationBar上的backButton是吧~

from rxwebviewcontroller.

JimWithJiang avatar JimWithJiang commented on July 3, 2024

是的,就是把navigationBar隐藏,为了达到满足各种效果,自己用UIView模拟的导航栏,点击调用 [self popViewControllerAnimated:YES],这种情况下就会类似多米诺骨牌,pop到rootViewController。我现在可以通过把你写得RxWebViewController的navigationBar隐藏,自己也这样写,暂时可解决这问题。我这有demo,需要的话您告诉我下邮件地址或发我邮件[email protected],我把demo给你。

from rxwebviewcontroller.

Roxasora avatar Roxasora commented on July 3, 2024

[email protected] 最近工作比较忙,抱歉可能不能及时回复,周末我会抽时间解决这个问题!谢谢反馈!!

from rxwebviewcontroller.

Roxasora avatar Roxasora commented on July 3, 2024

应该解决了,问题出在

    -(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.

tanranran avatar tanranran commented on July 3, 2024

上面那段代码还是有问题.... 其它页面点击返回 会出现 页面不返回 但是 titile 返回的样子 ...屏蔽掉这段代码.就不会影响其它页面了

from rxwebviewcontroller.

HHbreak avatar HHbreak commented on July 3, 2024

@tanranran 我这边也是,不知你解决了没有

from rxwebviewcontroller.

MonkeyS914 avatar MonkeyS914 commented on July 3, 2024

我也发现这个问题,后来发现作者
用下面这个方法截获系统返回操作时,没有处理不是 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.

tanranran avatar tanranran commented on July 3, 2024

@MonkeyS914 测试了下您的代码...还是有问题.

from rxwebviewcontroller.

MonkeyS914 avatar MonkeyS914 commented on July 3, 2024

还是你说的那个问题?导航栏返回了,但是页面没返回?我这边测试ok,其他的viewcontroller点击返回正常了

from rxwebviewcontroller.

Roxasora avatar Roxasora commented on July 3, 2024

@MonkeyS914 @tanranran @HHbreak 我更新了代码,放弃了之前的 category,使用了新的 RxWebViewNavigationViewController,大家将自己的 navigationController 继承到这个上面,pop 普通页面会产生的问题应该都修复了,大家看一下,有问题随时联系我~ 谢谢!!

from rxwebviewcontroller.

MonkeyS914 avatar MonkeyS914 commented on July 3, 2024

其实你没必要拦截系统的这个返回事件

直接修改这个方法就好
-(void)customBackItemClicked{
if (self.webView.canGoBack) {
[self.webView goBack];
}
else
{
[self.navigationController popViewControllerAnimated:YES];
}
}

from rxwebviewcontroller.

Roxasora avatar Roxasora commented on July 3, 2024

@MonkeyS914 你这里的 customBackItemClicked 方法是自己 subclass RxWebViewController 的时候添加的对吧,用于你自己重写了导航栏的状况是没问题的,但是如果是没有重写,仅仅是用系统提供的导航栏的情况是不是必须要拦截这个事件了呢~ 所以你的这种情况,其实可以把我的 category 或者 NavigationController 部分删掉,然后再加上你的这个方法就没问题了~~
感谢回复和支持~

from rxwebviewcontroller.

MonkeyS914 avatar MonkeyS914 commented on July 3, 2024

这个是你RxWebViewController 写的,我只是改了一下,因为觉得把我自己的navigationcontroller继承到你的那个NavigationController 感觉有点麻烦,于是就直接把demo里面的category删除了,修改了下你的返回的item响应方法。您的的这个效果实现思路很special,学习了,哈哈!

from rxwebviewcontroller.

1xiaocainiao avatar 1xiaocainiao commented on July 3, 2024

我也出现了楼上的bug,第一次正常进入web,退出,再次进入,点击返回就依然停留在web页面了.push之前的页面是隐藏了导航栏的,其他页面的导航栏是显示的

from rxwebviewcontroller.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.