ios – UISegmentedController在按两次相同的段后冻结

ios – UISegmentedController在按两次相同的段后冻结,第1张

概述我结合 Swift代码和第三方库(用Obj-C编写).我有一个带有UISegmentedController的UIViewController,我想在每次推送一个段或再次推送同一段时触发. 在我的Swift代码中,我有以下内容: override func viewDidLoad() { super.viewDidLoad() //setup ite 我结合 Swift代码和第三方库(用Obj-C编写).我有一个带有UISegmentedController的UIVIEwController,我想在每次推送一个段或再次推送同一段时触发.

在我的Swift代码中,我有以下内容:

overrIDe func vIEwDIDLoad() {        super.vIEwDIDLoad()        //setup        items = ["newTab".localized,"topTab".localized,"categoryTab".localized]        carbonTabSwipeNavigation = CarbonTabSwipeNavigation(items: items as [AnyObject],delegate: self)        carbonTabSwipeNavigation.insertIntoRootVIEwController(self)        self.style()        self.vIEw.userInteractionEnabled = true        carbonTabSwipeNavigation.carbonSegmentedControl!.addTarget(self,action: #selector(OvervIEwFolder.changesMade),forControlEvents: UIControlEvents.ValueChanged)    }func changesMade() {        switch carbonTabSwipeNavigation.carbonSegmentedControl!.selectedSegmentIndex {        case 0:            print("tab 1")        case 1:            print("tab 2")        case 2:            print("tab 3")        default:            print("nope")        }    }

在库中我添加了以下代码:

-(voID)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{    NSInteger current = self.selectedSegmentIndex;    [super touchesEnded:touches withEvent:event];    if (current == self.selectedSegmentIndex)        [self sendActionsForControlEvents:UIControlEventValueChanged];}

所以基本上我想在每次用户按下一个段时触发一个ValueChanged动作(即使它是同一个段).目前,当我按下相同的段时,它会第二次触发,但之后UISegmentController变得无响应(无法再切换段).

解决方法 最终对我有用的是:

- (voID)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {    [super touchesEnded:touches withEvent:event];    [self sendActionsForControlEvents:UIControlEventtouchUpInsIDe];}

carbonTabSwipeNavigation.carbonSegmentedControl!.addTarget(self,forControlEvents: UIControlEvents.touchUpInsIDe)
总结

以上是内存溢出为你收集整理的ios – UISegmentedController在按两次相同的段后冻结全部内容,希望文章能够帮你解决ios – UISegmentedController在按两次相同的段后冻结所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/web/1070766.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存