开发者

Using UISegmentControl as button

I have a segmentedbar control.

NSArray *optionsType = [NSArray arrayWithObjects: @"Geopoint", @"Directions", @" ", nil];
    segmentedOption = [[UISegmentedControl alloc] initWithItems:optionsType] ;

I am u开发者_StackOverflowsing one of the segmented bar "Geopoint" to show a subview (geopointView)when pressed.

test = [segmentedOption titleForSegmentAtIndex: [segmentedOption selectedSegmentIndex]];

if([test isEqualToString:@"Geopoint"])
[self.view addsubview:geopointViw];

When necessity of that "subview" is over, it is removed from superview.

[geopointview removefromsuperview];

all of these changes are occurring on same viewController. But now since sagmented bar "geopoint" is already pressed, it wont function until another segmented bar is pressed.

Is there any way so that I can reset segmentedcontrol?

thanks for any help in advance


If you don't want the segmented control to show the selected state, set,

segmentedControl.momentary = YES;

This makes the segments to work as buttons.


Use can use segmentedOption.selectedSegmentIndex = 1; while you remove subview from superview.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜