iPhone中这些控件的替代品有哪些

时间:2021-08-16 15:17:42

What are alternatives for these controls in iPhone

iPhone中这些控件的替代品有哪些

  • Radio Button
  • Check Box
  • Drop Down
  • x raise to Power y in UILabel
  • x在UILabel中加注到幂y

  • Hyperlink

Suggestion and answers will be appreciated, thanks.

建议和答案将不胜感激,谢谢。

2 个解决方案

#1


4  

Almost all of these controls can be displayed using a UIWebView - if that's not an option, have a look at the UIWebView implementations and it should give you some kind of idea.

几乎所有这些控件都可以使用UIWebView显示 - 如果这不是一个选项,请查看UIWebView实现,它应该给你一些想法。

However, if you want native controls, these are probably the best options:

但是,如果您想要本机控件,这些可能是最佳选择:

  • Radio Button: UISegmnetedControl
  • 单选按钮:UISegmnetedControl

  • Check Box: UISwitch
  • 复选框:UISwitch

  • Drop Down: UIPickerView (used in UIWebView).
  • 下拉:UIPickerView(在UIWebView中使用)。

x to the power of y in a UILabel is easy. Just replace your indices with unicode superscript characters... I use the following method to turn an integer into a string with superscript characters.

在UILabel中,x对y的幂很容易。只需用unicode上标字符替换索引...我使用以下方法将整数转换为带有上标字符的字符串。

+(NSString *)convertIntToSuperscript:(int)i {
    NSArray *array = [[NSArray alloc] initWithObjects:@"⁰", @"¹", @"²", @"³", @"⁴", @"⁵", @"⁶", @"⁷", @"⁸", @"⁹", nil];
    if (i >= 0 && i <= 9) {
        NSString *myString = [NSString stringWithFormat:@"%@", [array objectAtIndex:i]];
        [array release];
        return myString;
    }
    else {
        NSString *base = [NSString stringWithFormat:@"%i", i];
        NSMutableString *newString = [[NSMutableString alloc] init];
        for (int b = 0; b<[base length]; b++) {
            int temp = [[base substringWithRange:NSMakeRange(b, 1)] intValue];
            [newString appendString:[array objectAtIndex:temp]];
        }
        [array release];
        NSString *returnString = [NSString stringWithString:newString];
        [newString release];
        return returnString;
    }    
}

For a hyperlink, use a UITextView with Property Inspector -> Detection -> Links enabled and Editable behavior disabled. Of course this is also available in a UIWebView.

对于超链接,请使用带有Property Inspector的UITextView - >检测 - >启用链接并禁用可编辑行为。当然,这也可以在UIWebView中使用。

#2


7  

  • Radio Button: UISegmentedControl
  • 单选按钮:UISegmentedControl

  • Check Box: UISwitch
  • 复选框:UISwitch

  • Drop Down: UIPickerView
  • 下拉:UIPickerView

  • x raise to Power y in UILabel: no such thing, you need to draw it yourself.
  • x在UILabel中加注到Power y:没有这样的事情,你需要自己绘制它。

  • Hyperlink: Use a UILabel and attach a gesture recognizer for taps to it (or a custom type button)
  • 超链接:使用UILabel并附加手势识别器以点击它(或自定义类型按钮)

#1


4  

Almost all of these controls can be displayed using a UIWebView - if that's not an option, have a look at the UIWebView implementations and it should give you some kind of idea.

几乎所有这些控件都可以使用UIWebView显示 - 如果这不是一个选项,请查看UIWebView实现,它应该给你一些想法。

However, if you want native controls, these are probably the best options:

但是,如果您想要本机控件,这些可能是最佳选择:

  • Radio Button: UISegmnetedControl
  • 单选按钮:UISegmnetedControl

  • Check Box: UISwitch
  • 复选框:UISwitch

  • Drop Down: UIPickerView (used in UIWebView).
  • 下拉:UIPickerView(在UIWebView中使用)。

x to the power of y in a UILabel is easy. Just replace your indices with unicode superscript characters... I use the following method to turn an integer into a string with superscript characters.

在UILabel中,x对y的幂很容易。只需用unicode上标字符替换索引...我使用以下方法将整数转换为带有上标字符的字符串。

+(NSString *)convertIntToSuperscript:(int)i {
    NSArray *array = [[NSArray alloc] initWithObjects:@"⁰", @"¹", @"²", @"³", @"⁴", @"⁵", @"⁶", @"⁷", @"⁸", @"⁹", nil];
    if (i >= 0 && i <= 9) {
        NSString *myString = [NSString stringWithFormat:@"%@", [array objectAtIndex:i]];
        [array release];
        return myString;
    }
    else {
        NSString *base = [NSString stringWithFormat:@"%i", i];
        NSMutableString *newString = [[NSMutableString alloc] init];
        for (int b = 0; b<[base length]; b++) {
            int temp = [[base substringWithRange:NSMakeRange(b, 1)] intValue];
            [newString appendString:[array objectAtIndex:temp]];
        }
        [array release];
        NSString *returnString = [NSString stringWithString:newString];
        [newString release];
        return returnString;
    }    
}

For a hyperlink, use a UITextView with Property Inspector -> Detection -> Links enabled and Editable behavior disabled. Of course this is also available in a UIWebView.

对于超链接,请使用带有Property Inspector的UITextView - >检测 - >启用链接并禁用可编辑行为。当然,这也可以在UIWebView中使用。

#2


7  

  • Radio Button: UISegmentedControl
  • 单选按钮:UISegmentedControl

  • Check Box: UISwitch
  • 复选框:UISwitch

  • Drop Down: UIPickerView
  • 下拉:UIPickerView

  • x raise to Power y in UILabel: no such thing, you need to draw it yourself.
  • x在UILabel中加注到Power y:没有这样的事情,你需要自己绘制它。

  • Hyperlink: Use a UILabel and attach a gesture recognizer for taps to it (or a custom type button)
  • 超链接:使用UILabel并附加手势识别器以点击它(或自定义类型按钮)