iOS中在弹出的控制器的导航栏自动显示取消按钮以及自定义

iOS中在弹出的控制器的导航栏自动显示取消按钮以及自定义 Enable and change the custom cancel button follow these ways here:

自动显示默认的取消按钮的方法 A way to enable the normal appearance of custom cancel button

这里无需代码,将控制器作为弹出的导航控制器的根控制器即可。No more code here, use the view controller as the root controller of the navigation controller which present modally.

更改自定义取消按钮的外观和行为 Change the appearance and the event handler of custom cancel button

- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 更改自定义取消按钮的外观和行为
    self.customCancel_barButtonItem = [[UIBarButtonItem alloc] initWithImage:IMAGE(@"extreme.bundle/icon-close-modal") style:UIBarButtonItemStylePlain target:self action:@selector(buttonAction:)];
    
    // 另一种方式更改自定义取消按钮的行为
//    @WeakObject(self);
//    self.customCancelHandler = ^(id sender) {
//        @StrongObject(self);
//        [self performSelector:@selector(buttonAction:) withObject:sender];
//    };
}

- (void)buttonAction:(id)sender {
    self.customCancelHandler = nil;
}

相关

  • 详见极致框架官网<extreme.framework/EFBaseViewController.h>中自定义取消按钮部分的介绍。通过极致框架官网顶部的搜索功能搜索 customCancel_barButtonItem。

许可

  • 本文采用 BY-NC-SA 许可协议。即:署名——转载请注明出处;非商业使用;相同方式传播——再分发的文章许可与原文相同。

查看原文

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • iOS 提供了一些视图控制器转场动画(transition animation),如push、pop、presen...
    pro648阅读 4,626评论 0 3
  • 我是黑夜里大雨纷飞的人啊 1 “又到一年六月,有人笑有人哭,有人欢乐有人忧愁,有人惊喜有人失落,有的觉得收获满满有...
    陌忘宇阅读 12,728评论 28 53
  • 人工智能是什么?什么是人工智能?人工智能是未来发展的必然趋势吗?以后人工智能技术真的能达到电影里机器人的智能水平吗...
    ZLLZ阅读 9,391评论 0 5
  • 首先介绍下自己的背景: 我11年左右入市到现在,也差不多有4年时间,看过一些关于股票投资的书籍,对于巴菲特等股神的...
    瞎投资阅读 11,048评论 3 8
  • ![Flask](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAW...
    极客学院Wiki阅读 12,129评论 0 3