在iOS中配置弹出窗口
我想向用户显示一条弹出消息,但是我在查找文档时遇到了问题 以下是如何创建警报:在iOS中配置弹出窗口,ios,objective-c,Ios,Objective C,我想向用户显示一条弹出消息,但是我在查找文档时遇到了问题 以下是如何创建警报: UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wait" message:@"Are you sure you want to delete this. This action cannot be undone" delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cance
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Wait" message:@"Are you sure you want to delete this. This action cannot be undone" delegate:self cancelButtonTitle:@"Delete" otherButtonTitles:@"Cancel", nil];
[alert show];
我如何创建一个只显示以下内容的弹出窗口:
"Thanks for signing up!"
[ OK ]
在iOS 8之前使用UIAlertView
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:nil
message:@"Thanks for signing up"
delegate:self
cancelButtonTitle:nil
otherButtonTitles:@"OK", nil];
[alert show];
确保添加UIAlertViewDelegate。可以找到UIAlertView的文档,使用UIAlertController发布iOS 8
UIAlertController * alert= [UIAlertController alertControllerWithTitle:nil
message:@"Thanks for signing up"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {
//Do some thing here
[view dismissViewControllerAnimated:YES completion:nil];
}];
[alert addAction:ok];
[self presentViewController:alert animated:YES completion:nil];
可以在UIAlertController文档中找到这样做很容易
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thanks for signing up!" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
你在哪个iOS版本上做这个?在iOS8中,UIAlertView已被弃用,取而代之的是UIAlertController,请尝试搜索该视图。
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Thanks for signing up!" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];