• iOS 导航栏返回按钮时间action获取


    UIViewController+BackButtonHandler.h

    #import <UIKit/UIKit.h>

    @protocol BackButtonHandlerProtocol <NSObject>

    @optional

    // Override this method in UIViewController derived class to handle 'Back' button click

    -(BOOL)navigationShouldPopOnBackButton;

    @end

    @interface UIViewController (BackButtonHandler) <BackButtonHandlerProtocol>

    @end

    UIViewController+BackButtonHandler.m

    #import "UIViewController+BackButtonHandler.h"

    @implementation UIViewController (BackButtonHandler)

    @end

    @implementation UINavigationController (ShouldPopOnBackButton)

    - (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {

    if([self.viewControllers count] < [navigationBar.items count]) {

    return YES;

    }

    BOOL shouldPop = YES;

    UIViewController* vc = [self topViewController];

    if([vc respondsToSelector:@selector(navigationShouldPopOnBackButton)]) {

    shouldPop = [vc navigationShouldPopOnBackButton];

    }

    if(shouldPop) {

    dispatch_async(dispatch_get_main_queue(), ^{

    [self popViewControllerAnimated:YES];

    });

    } else {

    // Workaround for iOS7.1. Thanks to @boliva - http://stackoverflow.com/posts/comments/34452906

    for(UIView *subview in [navigationBar subviews]) {

    if(subview.alpha < 1.) {

    [UIView animateWithDuration:.25 animations:^{

    subview.alpha = 1.;

    }];

    }

    }

    }

    return NO;

    }

    方法提

    x x x.m

    -(BOOL) navigationShouldPopOnBackButton ///在这个方法里写返回按钮的事件处理

    {

        [self.navigationController popViewControllerAnimated:YES];

        

        return YES;

        

    }

    @end

  • 相关阅读:
    有关数据恢复的几个概念的理解
    cmsr 1.0.6
    Cmsr 1.0.5
    Cmsr 1.0.4
    vue中的v-model 与 .sync
    es6中clss做了些什么 怎么继承
    Cmsr 1.0.2
    Cmsr 1.0.1
    Cmsr 1.0.0
    VUE3.0新特性
  • 原文地址:https://www.cnblogs.com/aiwoqu/p/4708590.html
Copyright © 2020-2023  润新知