iOS 9.0 - 从 UIAlertController 操作中删除顶部栏 sheet
iOS 9.0 - Remove top bar from UIAlertController action sheet
使用 UIAlertController
创建操作 sheet 时,我看到顶部栏始终显示。这个 SO post 建议将标题设置为 nil
- 这可能适用于 iOS 8.0,但我在 iOS 9.0 上看到顶部栏。
你也把message
设置成nil
了吗?
这应该可以解决问题,至少对我有用 iOS9 (iPhone 6):
[UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
将 message
设置为 nil
还:
UIAlertController *actionSheet= [UIAlertController
alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *actionSheetButton1 = [UIAlertAction
actionWithTitle:@"Button 1"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
NSLog(@"Button 1 pressed");
}];
UIAlertAction *actionSheetButton2 = [UIAlertAction
actionWithTitle:@"Button 2"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
NSLog(@"Button 2 pressed");
}];
UIAlertAction *actionSheetButton3 = [UIAlertAction
actionWithTitle:@"Close Button"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
NSLog(@"Close Button pressed");
}];
[actionSheet addAction:actionSheetButton1];
[actionSheet addAction:actionSheetButton2];
[actionSheet addAction:actionSheetButton3];
[self presentViewController:actionSheet animated:YES completion:nil];
使用 UIAlertController
创建操作 sheet 时,我看到顶部栏始终显示。这个 SO post 建议将标题设置为 nil
- 这可能适用于 iOS 8.0,但我在 iOS 9.0 上看到顶部栏。
你也把message
设置成nil
了吗?
这应该可以解决问题,至少对我有用 iOS9 (iPhone 6):
[UIAlertController alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
将 message
设置为 nil
还:
UIAlertController *actionSheet= [UIAlertController
alertControllerWithTitle:nil
message:nil
preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *actionSheetButton1 = [UIAlertAction
actionWithTitle:@"Button 1"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
NSLog(@"Button 1 pressed");
}];
UIAlertAction *actionSheetButton2 = [UIAlertAction
actionWithTitle:@"Button 2"
style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action)
{
NSLog(@"Button 2 pressed");
}];
UIAlertAction *actionSheetButton3 = [UIAlertAction
actionWithTitle:@"Close Button"
style:UIAlertActionStyleCancel
handler:^(UIAlertAction * action)
{
NSLog(@"Close Button pressed");
}];
[actionSheet addAction:actionSheetButton1];
[actionSheet addAction:actionSheetButton2];
[actionSheet addAction:actionSheetButton3];
[self presentViewController:actionSheet animated:YES completion:nil];