English 中文(简体)
表格中选取多个项目——Beginner
原标题:Select multiple items from a tableview - Beginner

我需要增加一个<代码>可读,而且应当能够点击数。 www.un.org/chinese/ecosoc 缩略语

我知道,你必须为此使用<代码>NStable Dictionary。 但我不理解如何做到这一点。

请允许我指出一个好的理论或为我提供一些样本。

问题回答

You will have to use a delegate method for that.
First make sure your table view is set up well (delegate and datasource) and then
implement delegate s :
(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath.

You access the selected row index with : [indexPath row].
And then you can store this value.

THere在Cocoa With Love上担任职务,你可能会发现这一点。

定点,但原则相同。

It really depends on your data model. First of all you need a NSMutableArray not a NSMutableDictionary;

//declare an NSMutableArray in the interface
@interface Class : SuperClass {
NSMutableArray *_arrayWithMySelectedItems;
}

//in one of your init/preparation methods alloc and initialize your mutable array;

- (void)viewDidLoad {
[super viewDidLoad];

_arrayWithMySelectedItems = [NSMutableArray alloc] init];
}

//now before you forget it add release in your dealloc method

- (void)dealloc {
[_arrayWithMySelectedItems release];

[super dealloc];
}

//add this following code to your didSelect Method part of tableView s delegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//if you have only one category, you will probably have something like this
[_arrayWithMySelectItems addObject:[dataModelArray objectAtIndex:indexPath.row];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}

您可在这一方法中使用NSMutableDictionary:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSMutableDictionary *dict = [NSMutableDictionary alloc] init];
    [dict setObject:[NSString stringWithFormat:"%@", cell.Label.text] forKey:[NSString stringWithFormat:"Key%d", indexPath.row]];
}

然后,宣布在座标的斜体内进行扼杀,然后根据你的愿望,将座标=[人口稠密阵标AtIndex:indexpath.row];然后添加到字典或可变阵列中。





相关问题
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风格的解决办法,只是一个简单的袖珍流程......

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

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

热门标签