の選択した行を内部UITableView
から更新しようとしています。しかし、私は問題に直面しています。行を更新しようとするたびに、行の選択に関係なく、最初の行のみが更新されます。
私のコードは次のとおりです。UIAlertView
didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *selectedrow = nil;
if (searching) {
slCell=indexPath.row;
selectedrow = [copyListOfItems objectAtIndex:indexPath.row];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Enter the Number of Quantity" message:@""
delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert addTextFieldWithValue:@"" label:@"Number of Item"];
textfieldQty = [alert textFieldAtIndex:0];
textfieldQty.keyboardType = UIKeyboardTypeNumberPad;
textfieldQty.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldQty.autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];
[alert release];
}
else {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Enter the Number of Quantity" message:@""
delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
[alert addTextFieldWithValue:@"" label:@"Number of Item"];
textfieldQty = [alert textFieldAtIndex:0];
textfieldQty.keyboardType = UIKeyboardTypeNumberPad;
textfieldQty.keyboardAppearance = UIKeyboardAppearanceAlert;
textfieldQty.autocorrectionType = UITextAutocorrectionTypeNo;
[alert show];
[alert release];
}
}
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
NSString *b=nil;
if (buttonIndex == 0) {
if (searching) {
if([textfieldQty.text isEqualToString:b]) {
UIAlertView *alert2 = [[UIAlertView alloc] initWithTitle:@"Enter plz" message:@""
delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK"];
[alert2 show];
[alert2 release];
}
NSString *newqty = [[NSString alloc] initWithFormat:@"%@",textfieldQty.text];
DMSAppDelegate *d= (DMSAppDelegate *)[[UIApplication sharedApplication] delegate];
[d->tableDataQt replaceObjectAtIndex:slCell withObject:(id)newqty];
NSLog(@"tb%@",copyListOfQty);
}
else {
NSString *newqty = [[NSString alloc] initWithFormat:@"%@",textfieldQty.text];
DMSAppDelegate *d= (DMSAppDelegate *)[[UIApplication sharedApplication] delegate];
[d->tableDataQt replaceObjectAtIndex:slCell withObject:(id)newqty];
[self.tablevieww reloadData];
}
}
}