[英]IOS UIAlertView not showing up
I want to pop up a simple message window when a user touches the button, in an IPhone app. 当用户触摸iPhone应用程序中的按钮时,我想弹出一个简单的消息窗口。 I used UIAlertView class, in the implementation code like this:
我在实现代码中使用了UIAlertView类,如下所示:
-(IBAction)sendMessage:(UIButton *)sender
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"test message"
message:@"test"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
I also linked sendMessage method action to touch up inside. 我还链接了sendMessage方法操作以进行内部修饰。
Shows nothing. 什么也没显示。
Have any ideas? 有什么想法吗? I'm new to iOS programming.
我是iOS编程的新手。 Thanks for helping.
感谢您的帮助。
您需要将情节提要/ xib文件中的按钮链接到函数或调用或通过代码进行设置
[button addTarget:self action:@selector(sendMessage:) forControlEvents:UIControlEventTouchUpInside];
I would suggest two things, give it a try: 我建议两件事,尝试一下:
1) Set delegate
to self
. 1)将
delegate
设置为self
。
2) Try making the IBAction argument type to id
. 2)尝试将IBAction参数类型设置为
id
。 Then remove and reconnect from Interface builder. 然后从“接口”构建器中删除并重新连接。
Something like this: 像这样:
-(IBAction)sendMessage:(id)sender
{
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"test message"
message:@"test"
delegate:self
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
}
NSString* messageString = [NSString stringWithFormat: @"\"%@ \"does not apppear to be valid email address.Do You Want sent Anyway?", email];
UIAlertView *alertView =[[UIAlertView alloc]initWithTitle:@"Invalid adress" message:messageString delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"OK", nil];
[alertView show];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.