0
我有3個不同的數組。 1)ids 2)名稱3)用於emailid。從tableview中獲取選定值時的問題
我在tableview中顯示名字。
並在tableview中顯示帶勾選標記的選定名稱。
現在我需要從id和emailid數組中獲得選定的姓名ID和電子郵件。
而檢索到的id和電子郵件需要保存在兩個不同的數組中。
對我的代碼是
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
// Customize the number of rows in the table view.
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.sourceArray count];;
}
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
[cell.textLabel setText:[self.sourceArray objectAtIndex:indexPath.row]];
if ([self.selectedArray containsObject:[agentemails objectAtIndex:indexPath.row]]){
NSLog(@"111111111111");
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
else
{
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
if ([self.selected_agentid_email containsObject:[agentids objectAtIndex:indexPath.row]]){
NSLog(@"222222222222");
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
else
{
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
if(myBoolean){
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
return cell;
}
#pragma mark -
#pragma mark Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if ([self.selectedArray containsObject:[agentemails objectAtIndex:indexPath.row]]){
NSLog(@"33333333333333");
[self.selectedArray removeObjectAtIndex:[self.selectedArray indexOfObject:[agentemails objectAtIndex:indexPath.row]]];
}
else
{
[self.selectedArray addObject:[agentemails objectAtIndex:indexPath.row]];
}
if ([self.selected_agentid_email containsObject:[agentids objectAtIndex:indexPath.row]]){
NSLog(@"4444444444444444");
[self.selected_agentid_email removeObjectAtIndex:[self.selected_agentid_email indexOfObject:[agentids objectAtIndex:indexPath.row]]];
}
else
{
[self.selected_agentid_email addObject:[agentids objectAtIndex:indexPath.row]];
}
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationNone];
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
,但我得到的問題是,
例如:如果我選擇在實現代碼如下3名,我能夠檢索只有一個EMAILID和3個IDS。
我沒有得到什麼問題是。
任何人都可以幫助我。
謝謝你提前。
感謝ü喬,但我沒有得到我在哪裏可以給代理ID和代理email.I我還未得到 - (空)的tableView:(UITableView的*)的tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath {你可以用一些解釋編輯它 – MaheshBabu 2011-02-02 03:59:17