在我的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在按两次相同的段后冻结所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)