ios - UISegmentedController freezes after pressing same segment twice -


i combining swift code , third party library (written in obj-c). have uiviewcontroller u uisegmentedcontroller in, want trigger each time segment has been pushed or the same segment pushed again.

in swift code, have following:

override func viewdidload() {         super.viewdidload()         //setup         items = ["newtab".localized,"toptab".localized,"categorytab".localized]         carbontabswipenavigation = carbontabswipenavigation(items: items [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")         }     } 

in library have added following code:

-(void)touchesended:(nsset *)touches withevent:(uievent *)event {     nsinteger current = self.selectedsegmentindex;     [super touchesended:touches withevent:event];     if (current == self.selectedsegmentindex)         [self sendactionsforcontrolevents:uicontroleventvaluechanged]; } 

so want trigger valuechanged action every time user presses segment (even if it's same segment). triggers second time when press same segment, after uisegmentcontroller becomes unresponsive (can't switch segments anymore).

what worked me following:

- (void)touchesended:(nsset *)touches withevent:(uievent *)event {     [super touchesended:touches withevent:event];      [self sendactionsforcontrolevents:uicontroleventtouchupinside]; } 

and

carbontabswipenavigation.carbonsegmentedcontrol!.addtarget(self, action: #selector(overviewfolder.changesmade), forcontrolevents: uicontrolevents.touchupinside) 

Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -