解决返回按钮消息处理的问题

2017-10-17  本文已影响0人  油麦菜洋葱头

网上流传一个高人写的类文件,UIViewController+BackButtonHandler,但我尝试多次,都不进入重载的消息里面,不知道为何,新建了一个空的工程,也无效,无奈,只好曲线救国

直接上代码:

UIButton*transparentButton = [[UIButtonalloc]init];

[transparentButtonsetFrame:CGRectMake(0,0,100,40)];

[transparentButtonsetBackgroundColor:[UIColorclearColor]];

[transparentButtonaddTarget:selfaction:@selector(clickBtnBack)forControlEvents:UIControlEventTouchUpInside];

[self.navigationController.navigationBaraddSubview:transparentButton];

原理:定义一个透明按钮,这样既不影响默认的返回按钮样式,又可以对消息进行拦截

上一篇 下一篇

猜你喜欢

热点阅读