显示与可可的警报

Fai*_*sal 2 cocoa-touch ios

我已经使用VB.NET一段时间了,我切换到Xcode 4.

在VB.NET环境中,我曾经在一个按钮中输入以下命令:

if TextBox1.text="" then
    MessageBox.Show("You can't leave the textbox empty!, "Error!")
else
    Label1.text = TextBox1.text
Run Code Online (Sandbox Code Playgroud)

这只是一个例子.在Xcode中,我想做同样的事情,除了我想要一个弹出警报(在iPhone中)而不是VB.NET中的MessageBox.

有任何想法吗?

Rah*_*yas 5

干得好

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;
}
Run Code Online (Sandbox Code Playgroud)