0

SQLite データベースから情報を取得し、TableView 内のセルにデータを入力するアプリケーションがあります。ただし、ユーザーがセルをクリックして、AlertView を介してそのセル内のコンテンツを編集できるようにしたいと考えています。以下は私のコードの一部です:

    //Set up cell
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:    (NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];


cell.textLabel.text = [resultSet objectAtIndex:indexPath.row];

return cell;
}

-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath{

CustomCell *cell = [tableView cellForRowAtIndexPath:indexPath];

UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Question" message:@"Please enter a new question" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
av.alertViewStyle = UIAlertViewStylePlainTextInput;
txtNewQuestion = [av textFieldAtIndex:0];
txtNewQuestion.clearButtonMode = UITextFieldViewModeWhileEditing;
av.delegate = self;
[txtNewQuestion setPlaceholder:@"new Question"];
[av show];
[self.txtNewQuestion becomeFirstResponder];
}

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex  {



if (buttonIndex == 1) {

    CustomCell *cell;
    enteredQuestion = txtNewQuestion.text;
    cell.customLabel.text = enteredQuestion;
    NSLog(@"%@", enteredQuestion);
    NSLog(@"%@", cell.customLabel.text);

}
[self.tableView reloadData];

}

どんな援助でも大歓迎です。ありがとう。

4

2 に答える 2

0

UIAlertView デリゲートでセルを取得するにはどうすればよいですか? をどのように保存しenteredQuestionますか?

呼び出すとreloadData、テーブル全体が再構築されます(ドキュメント)

于 2014-06-10T14:11:39.397 に答える