显示与Cocoa的警报 [英] Showing an alert with Cocoa
本文介绍了显示与Cocoa的警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我一直在使用VB.NET一段时间,我切换到Xcode 4。
I have been using VB.NET for a while and I switched to Xcode 4.
在VB.NET环境中,我用来键入以下命令一个按钮:
In the VB.NET environment, I used to type the following command in a button:
if TextBox1.text="" then
MessageBox.Show("You can't leave the textbox empty!, "Error!")
else
Label1.text = TextBox1.text
$ b b
这只是一个例子在Xcode中,我想做同样的事情,除了我想有一个弹出警报(在iPhone中),而不是VB.NET中的MessageBox。
That is just an example. In Xcode, I want to do the same thing except for I want to have a Pop-Up Alert (in the iPhone) instead of the MessageBox in VB.NET.
任何想法?
推荐答案
if ([TextBox1.text isEqualToString:@""]){
UIAlertView *errorAlert = [[UIAlertView alloc] initWithTitle:@"Error"
message:@"You can't leave the textbox empty!"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[errorAlert show];
[errorAlert release];
} else {
Label1.text = TextBox1.text;
}
这篇关于显示与Cocoa的警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文