• 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

  • 相关阅读:
    Asp.Net Core&Docker部署到树莓派3B中
    KnockoutJS-与服务端交互
    服务部署到Swarm Cluster中
    新建项目加入到生成流水线中
    约定Service构建方式
    约定Jenkins构建脚本
    约定新项目的搭建流程
    设计生成自动化流水线
    新建项目到Jenkins中
    把ABP框架部署到Docker中
  • 原文地址:https://www.cnblogs.com/aiwoqu/p/4708590.html
Copyright © 2020-2023  润新知