以简单的方式自定义UIAlertView

时间:2014-05-19 02:35:56

标签: ios uitableview uialertview

我对堆栈的问题是如何自定义“消息”#39; UIAlertView的一部分。现在,消息是[dbName],它是表中的选定行。我如何才能将消息更改为类似的内容。 @"你想添加' dbName'到数据库?"

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{


Database * currentStore = [DBList objectAtIndex:indexPath.row];
NSString *dbName = currentStore.databaseName;


UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camaleon Alert" message:dbName delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];
// optional - add more buttons:
[alert addButtonWithTitle:@"Add"];
[alert show];




}

1 个答案:

答案 0 :(得分:0)

简单的事情:

NSString *messageString = [NSString stringWithFormat:@"Would you like to add '%@' to the database?",currentStore.databaseName];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Camaleon Alert" messageString delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil];