【问题标题】:How to set the UISegmentControl as selected and multiple touches for selected index?如何将 UISegmentControl 设置为选定并为选定索引设置多次触摸?
【发布时间】:2012-09-06 00:50:41
【问题描述】:

我有一个问题:我的 UISegmentedControl 具有三个索引 0、1、2。当我选择 UISegmentedControl 的索引时,它工作正常,但我需要进行多次触摸,并且应该关注它是如何实现的。如何编程以再次点击选定的索引,它应该可以工作......

     NSArray *segmentTextContent = [NSArray arrayWithObjects: allString, favoritesString,filterString, nil];
segmentedControl = [[UISegmentedControl alloc] initWithItems:segmentTextContent];
[segmentedControl setFrame:CGRectMake(60,10,200,30)];
[segmentedControl addTarget:self action:@selector(segmentAction:) forControlEvents:UIControlEventValueChanged];
//segmentedControl.momentary = YES;

segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
segmentedControl.tintColor=[UIColor colorWithRed:36/255.0 green:61/255.0 blue:103/255.0 alpha:1];
segmentedControl.selectedSegmentIndex =0;
[toolBar1 addSubview:segmentedControl];

【问题讨论】:

  • 有点混乱...请​​再试一次?
  • 选中的一个是专注的并调用声明的动作并正常工作,然后我再次点击它应该再次调用的同一个按钮
  • 有什么想法或方法可以为 UISegmentedControl 设置多个事件

标签: iphone objective-c uisegmentedcontrol


【解决方案1】:
mySegmentedControl.momentary = YES;

我相信这是你想要的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-10
    相关资源
    最近更新 更多