Showing an alert with Cocoa

独自空忆成欢 提交于 2020-01-14 01:58:08

问题


I have been using VB.NET for a while and I switched to Xcode 4.

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

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.

Any Ideas?


回答1:


Here you go

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;
}


来源:https://stackoverflow.com/questions/6424891/showing-an-alert-with-cocoa

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!