0
我創建了一個表格有了一些選項列表,其中一個是「添加新行」。如果用戶點擊它,他將得到一個警報視圖.i使用文本字段自定義該警報視圖。但問題是我無法將輸入到文本字段中的數據添加到我的表格視圖中。如何從警報視圖添加數據到我的表
有人請幫忙。
- (void)tableView:(UITableView *)aTableView commitEditingStyle: (UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
if (editingStyle == UITableViewCellEditingStyleDelete)
{
[self.listOfCategories removeObjectAtIndex:indexPath.row];
[self.tableViewC reloadData];
}
else if (editingStyle == UITableViewCellEditingStyleInsert)
{
UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Your title here!" message:@"...." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setBackgroundColor:[UIColor whiteColor]];
[myAlertView addSubview:myTextField];
[myAlertView show];
[myAlertView release];
[self.listOfCategories insertObject:@"Add" atIndex:[self.listOfCategories count]];
[self.tableViewC reloadData];
}
也許表現出一定的代碼,你到目前爲止,你已經嘗試把文本在表格等 – ophychius
你必須使用UIAlertViewDelegate方法。查看相關文檔。 – vikingosegundo
這裏是我卡住....我不知道下一步該怎麼做 – Chandu