Ngine-UISegmentedControl enamasegimenti ama-3 futhi ngifuna ukushintsha ububanzi besigaba 1 esisodwa lapho umsebenzisi ekhetha noma iyiphi ingxenye. Nayi ikhodi:
// the UISegmentedControl is created
[segmentedControl addTarget:self action:@selector(changeIt:)
forControlEvents:UIControlEventValueChanged];
//...
// and this is the changeIt method:
- (void) changeIt:(id)sender {
// discover the original width of segment 1, to restore it later
UISegmentedControl *seg = (UISegmentedControl*)sender;
CGFloat segWidth = [seg widthForSegmentAtIndex:1];
// At this point segWidth = 0 ?????????????????
// note: seg is not nil at this point. Printing seg to console shows it is
// a valid UISegmentedControl...
}
Noma yiziphi izinkomba? Ngiyabonga.