iphone使用什么,因为没有“单选按钮" [英] iphone what to use as there are no "radio buttons"

查看:47
本文介绍了iphone使用什么,因为没有“单选按钮"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于iPhone,我无法找到触发单组中其他按钮的单选按钮.那么每个人都建议使用什么?UISwitch我猜想并做了一些事情来在选择另一个时触发组中的其他人?

For the iPhone, I havent been able to find anything like a radio button that triggers the other buttons in a group. So what would everyone suggest using? UISwitch I guess and do something to trigger the others in the group when an other is selected?

如果我有多个UISwitch对象,如何触发其他对象与我切换的对象相反?

If I had several UISwitch objects how would I trigger the others to be the opposite of what I switched?

推荐答案

我还使用了自定义UISegmentedControl.像这样:

I also used a custom UISegmentedControl. Something like this:

NSMutableArray* buttons;

- (void)touchDownAction:(UIButton*)button {
    [self dimAllButtonsExcept:button];
    if ([delegate respondsToSelector:@selector(touchDownAtSegmentIndex:)])
        [delegate touchDownAtSegmentIndex:[buttons indexOfObject:button]];
}

-(void) dimAllButtonsExcept:(UIButton*)selectedButton {
    for (UIButton* button in buttons) {
        if (button == selectedButton) {
            button.selected = YES;
            button.highlighted = YES;
        } else {
            button.selected = NO;
            button.highlighted = NO;
        }
    }
}

完整代码位于 https://github.com/j4n0/jobsket/tree/master/sources/main/ui/custom/segControl

这篇关于iphone使用什么,因为没有“单选按钮"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆