在UIAlertView中调用NSString



嘿,我正在使用theos进行编码,我希望NSString的值显示在下面UIAlertView上的字段中,我该如何编写呢?在这里:

UIAlertView *quickreply = [[UIAlertView alloc] initWithTitle:@"%@" message:@"%@" delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Reply", nil];

我试过在引号后面写一个,NSStringID,但它会给整个UIAlertView带来错误,所以我想知道我应该如何编码它,我应该在引号中使用括号还是更多引号,或者括号"还是什么?

请帮助

字符串WithFormat就是您想要的,请尝试以下操作:

NSString *title = [NSString stringWithFormat:@"title is %@", @"my title"];
NSString *msg = [NSString stringWithFormat:@"message is %@", @"my message"];
UIAlertView *quickreply = [[UIAlertView alloc] initWithTitle:title message:msg delegate:self cancelButtonTitle:@"Close" otherButtonTitles:@"Reply", nil];

使用:

[NSString stringWithFormat:@"%@", theString];

如果你想那样做的话。希望能有所帮助!

NSString *message = [NSString stringWithFormat:@"%@",myIvar];

将UIAlertView的消息设置为消息NSString

最新更新