GithubHelp home page GithubHelp logo

Back button highlight about swipeback HOT 8 CLOSED

panzerdp avatar panzerdp commented on May 27, 2024
Back button highlight

from swipeback.

Comments (8)

devxoul avatar devxoul commented on May 27, 2024

Hi @panzerdp ,
Thanks for your bug report. I've tested for some cases, then I found that interactiveGestureRecognizer cancels navigation button's touch event. I just add some code that enables navigation button highlighting.

from swipeback.

panzerdp avatar panzerdp commented on May 27, 2024

Hi @devxoul,
thanks for your quick answer and fix.
I installed the 1.0.2 version and the custom back button is highlighted, but... the swipe back is not working. What could be the problem?
Tested in iOS 8 simulator, Xcode 6.2 beta, built using Swift.
Thanks.

from swipeback.

devxoul avatar devxoul commented on May 27, 2024

I tested in iOS 8 simulator with Xcode 6.1 and works fine. I've just downloaded Xcode 6.2 beta, and gonna test again. While testing, how about check this demo project? It's still in progress but you can test with environment that I developed in. Thanks.

from swipeback.

devxoul avatar devxoul commented on May 27, 2024

I found something strange that SwipeBack 1.0.2 installed via CocoaPods doesn't work properly. I removed calling load of super then works fine. I released 1.0.3 version, check for these:

Thank you.

from swipeback.

panzerdp avatar panzerdp commented on May 27, 2024

I installed the 1.0.3 version and it works better.
In my case I have a back button with custom background image only, without text and unfortunately it is not highlighted. When using a simple button with text, it does highlight.
I checked also the demo version, it works well with textual back button, but no example with background image.
Thanks.

from swipeback.

panzerdp avatar panzerdp commented on May 27, 2024

I searched more in the code and managed to find a solution.
It seems like you highlight the UINavigationButton, as a descendant of the Navigation Bar. But in my particular case, I have a UIButton in navigation button, which catches the gesture. I've added the highlight to UIButton, and it works correct.
I've updated UINavigationController+SwipeBack.m with the following:

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
    Class UINavigationButton = NSClassFromString(@"UINavigationButton");
    Class UIButtonClass = NSClassFromString(@"UIButton");
    if (([touch.view isKindOfClass:UINavigationButton] || [touch.view isKindOfClass:UIButtonClass]) && [touch.view isDescendantOfView:self.navigationBar]) {
        UIButton *button = (id)touch.view;
        button.highlighted = YES;
    }
    return YES;
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    CGPoint location = [gestureRecognizer locationInView:self.navigationBar];
    UIView *view = [self.navigationBar hitTest:location withEvent:nil];

    Class UINavigationButton = NSClassFromString(@"UINavigationButton");
    Class UIButtonClass = NSClassFromString(@"UIButton");
    if (([view isKindOfClass:UINavigationButton] || [view isKindOfClass:UIButtonClass]) && [view isDescendantOfView:self.navigationBar]) {
        UIButton *button = (id)view;
        button.highlighted = NO;
    }
    return YES;
}

I made some initial tests, it seems to work correct.
Let me know what you think.
Thanks.

from swipeback.

devxoul avatar devxoul commented on May 27, 2024

Cool. Since UINavigationButton is a subclass of UIButton, so we can just put this code instead:

if ([view isKindOfClass:[UIButton class]] && [view isDescendantOfView:self.navigationBar]) {
    ...
}

I just released 1.0.4 to CocoaPods.
Thank you for your time @panzerdp :D

from swipeback.

panzerdp avatar panzerdp commented on May 27, 2024

Agreed, we can use UIButton.
Thanks for your time too. I'm glad to have this working :)

from swipeback.

Related Issues (8)

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.