iphone - iPad UIActionSheet 不显示

标签 iphone cocoa-touch uiactionsheet

我使用了 this 中的代码发布以在我的应用程序中显示操作表。但它显示像

enter image description here

原因是什么?

我显示操作表的代码是

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:nil 
                                                         delegate:nil
                                                cancelButtonTitle:nil
                                           destructiveButtonTitle:nil
                                                otherButtonTitles:nil];

[actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

CGRect pickerFrame = CGRectMake(0, 40, 300, 300);

UIView *pickerView = [[UIView alloc] initWithFrame:pickerFrame];
pickerView.backgroundColor=[UIColor blackColor];

[actionSheet addSubview:pickerView];


UISegmentedControl *closeButton = [[UISegmentedControl alloc] initWithItems:[NSArray arrayWithObject:@"Close"]];
closeButton.momentary = YES; 
closeButton.frame = CGRectMake(260, 7.0f, 50.0f, 30.0f);
closeButton.segmentedControlStyle = UISegmentedControlStyleBar;
closeButton.tintColor = [UIColor blackColor];
[closeButton addTarget:self action:@selector(dismissActionSheet:) forControlEvents:UIControlEventValueChanged];
[actionSheet addSubview:closeButton];


[actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

[actionSheet setBounds:CGRectMake(0, 0, 320, 485)];

[self.view addSubview:actionSheet];

最佳答案

替换

 [actionSheet showInView:[[UIApplication sharedApplication] keyWindow]];

 [actionSheet showFromRect:btnShare.frame inView:self.view animated:YES];

或者如果您想要 iPad 中的操作表,请尝试此自定义控件 https://nodeload.github.com/Arrived/BlockAlertsAnd-ActionSheets/zipball/master

关于iphone - iPad UIActionSheet 不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9496259/

相关文章:

iphone - iOS 4 支持一种方式吗?

iphone - 如何添加代码来更新在线 "counter",以便我知道 iPhone 应用程序被打开了多少次?

ios - 如何使用 loginViewFetchedUserInfo 获取用户电话号码?

objective-c - 在 UIButton 的背景图片上自定义绘图

ios - 呈现 View Controller 也可以是呈现 View Controller 吗?

cocoa-touch - iOS 获取类似 ActionSheet 的按钮

iphone - 在一个 View Controller 中强制肖像使其他 View Controller 最初处于肖像

ios - 关键帧动画关键时间

ios - actionSheet :didDismissWithButtonIndex: is deprecated in iOS 8. 3. 我现在必须使用的新方法是什么?

ios - 如何查找 UIActionSheet 文本的大小和字体?