iOS 中没有图块的弹出窗口

Popup without tile in iOS

我想在单击工具栏上的按钮时显示弹出窗口。我正在使用 ios 8 SDK。

我正在使用下面的代码来做同样的事情,但现在我想从中删除标题。

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:[appDelegate encTitle]
                                                          delegate:self cancelButtonTitle:nil destructiveButtonTitle:nil
                                                otherButtonTitles:@"Add Bookmark", @"Cancel",nil];
actionSheet.actionSheetStyle = UIActionSheetStyleDefault;
actionSheet.cancelButtonIndex = 1;  // make the second button red (destructive)
[actionSheet showInView:self.view]; // show from our table view (pops up in the middle of the table)
[actionSheet release];

如果我像这样使用 initWithTitle:@"" 那么标题块也会出现在弹出窗口中。

目前如下图

想达到这样的效果

请帮我解决这个问题。

按照 sweetAngel 的建议使用 UIalertviewController 后,iPhone 4s 就变成这样....请帮助在所有设备上正确显示它。

在 iOS 8 中,您不仅应该定义 使用 retain / release,而且为了呈现一个动作 sheet 您应该使用 UIAlertController 因为 UIActionSheet 已被弃用。这是一个例子:

UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:@"Evacuate Building!" message:@"" preferredStyle:UIAlertControllerStyleActionSheet];



UIAlertAction *destructiveAction = [UIAlertAction actionWithTitle:@"Kick through door" style:UIAlertActionStyleDestructive handler:^(UIAlertAction *action) {
    // destructive action completion
}];

UIAlertAction *defaultAction = [UIAlertAction actionWithTitle:@"Walk calmly" style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) {
    // default action completion
}];

UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Do nothing" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {
    // cancel action completion
}];

[actionSheet addAction:destructiveAction];
[actionSheet addAction:defaultAction];
[actionSheet addAction:cancelAction];

[self presentViewController:actionSheet animated:YES completion:nil];

如果您使用的是 iOS 8,那么您可以试试这个:

UIAlertController *alert1 = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];

UIAlertAction* ok = [UIAlertAction actionWithTitle:@"Add Bookmark" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
    // Your code for bookmark
    [alert1 dismissViewControllerAnimated:YES completion:nil];
}];
UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) {
    [alert1 dismissViewControllerAnimated:YES completion:nil];
}];

[alert1 addAction:ok];
[alert1 addAction:cancel];
[self presentViewController:alert1 animated:YES completion:nil];