首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >多行UISegmentedControl

多行UISegmentedControl
EN

Stack Overflow用户
提问于 2011-02-05 11:11:45
回答 2查看 2.4K关注 0票数 3

如何制作多行UISegmentedControl?我需要它有6个按钮,每行3个。我如何通过编程来做到这一点呢?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2011-02-05 11:18:41

您将需要使用其中的两个,并使用selectedSegmentIndex属性。当你从一个控件获取一个动作时,如果你将另一个控件的属性值设置为-1,那么它将有效地为你提供两行中的六个按钮,它们看起来像是链接在一起作为一个组。

票数 6
EN

Stack Overflow用户

发布于 2013-09-23 17:47:19

只需在@Adam EberBach的答案中添加代码:

viewDidLoad

代码语言:javascript
复制
[self.orderOptionsSegmentedControl1 addTarget:self action:@selector(disableOtherSegmentedControl:) forControlEvents:UIControlEventValueChanged];
[self.orderOptionsSegmentedControl2 addTarget:self action:@selector(disableOtherSegmentedControl:) forControlEvents:UIControlEventValueChanged];

然后实现disableOtherSegmentedControl

代码语言:javascript
复制
- (void) disableOtherSegmentedControl:(id)sender
{
    if (sender == self.orderOptionsSegmentedControl1)
    {
        self.orderOptionsSegmentedControl2.selectedSegmentIndex = -1;
    }

    else if (sender == self.orderOptionsSegmentedControl2)
    {
        self.orderOptionsSegmentedControl1.selectedSegmentIndex = -1;
    }
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4904881

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档