English 中文(简体)
视国家为特点的听器
原标题:pickerview for iphone that looks like country select feature

I want to create a picker that looks and works like the country select field of itune store account. Here is what I am talking about.

http://i38.tinypic.com/5p0w91.jpg

This picker doesn t have a row highlighted. It has "correct" sign marked in front of selected row. user can scroll this picker and then select the row so "correct" sign will appear in front of newly selected row. Can someone please help?

问题回答

这一点可以比较容易地利用带有习俗成分观点的选子来实现。 利用实例变量跟踪你选定的行文,并相应改变你的标识。 如果你想要列入检查标记,那么你需要走一步,使用“IDView”的门槛,而不是简单的“IDLabel”。


@interface ViewContainingPicker
{
    NSUInteger mySelectedRow;
}
@end

@implementation ViewContainingPicker

// Init, Picker setup, etc
- (UIPickerView *)myPickerView
{
    // Create picker, set mySelectedRow to NSNotFound
    mySelectedRow = NSNotFound;
    return myPickerView;
}

- (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view
{
    UILabel *label = (UILabel *)view;

    if (nil == label) {
        UILabel *label = [[[UILabel alloc] initWithFrame:CGRectMake(0, 0, PICKER_WIDTH, PICKER_ROW_HEIGHT)] autorelease];
    }

    label.text = @"Label for this row";

    // Selected Row will be blue
    if (row == mySelectedRow) {
        label.textColor = [UIColor blueColor];
    } else {
        label.textColor = [UIColor blackColor];
    }

    return label;
}

- (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
{
    // Just set selected component and reload, color will change in dataSource pickerView:viewForRow:forComponent:reusingView:
    mySelectedRow = row;
    [pickerView reloadComponent:component];
}

我不熟悉编码系统,而对于以浏览器为基础的电子数据系统(Safari)来说,你只是使用一种简单的下降菜单:

<select>
<option>Country 1</option>
<option>Country 2</option>
...
<option>Country N</option>
</select>

无论哪一种东西都一样,都应当做到同样。





相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签