如何去除 iPad 日期选择器后面的黑点背景

发布于 2025-01-05 22:33:56 字数 223 浏览 4 评论 0原文

我为 iPhone 开发了一个应用程序。我已将同一个应用程序移植到 iPad 上。

所有视图都运行良好。

但日期采摘者周围有一个长长的黑暗背景。

即使我在 IB 尺寸检查器中更改了尺寸,它也没有改变

我应该如何去除这个黑点?

这是我的日期选择器的图像

I developed an application for iPhone. I have ported this same app to iPad.

All the views are working perfectly.

But the date pickers have a long dark back ground around them.

It doesn't change even I changed size in size inspector of IB

How should i remove this dark spot?

This is the image of my date picker

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

你是我的挚爱i 2025-01-12 22:33:56

试试这个:

[[datePicker.subviews objectAtIndex:0] removeFromSuperview];
[datePicker setBackgroundColor:[UIColor clearColor]];

Try this:

[[datePicker.subviews objectAtIndex:0] removeFromSuperview];
[datePicker setBackgroundColor:[UIColor clearColor]];
烈酒灼喉 2025-01-12 22:33:56

你好,Ur 的 Truly Prasad,

实现 UIPickerView 的更好方法,有两种方法可以显示 UIPicker 视图,其中更可取

1)您可以将子视图放在 UIAlertview 上
以下代码。

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

    [self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

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

    self.pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];

    self.pickerView.showsSelectionIndicator = YES;
    self.pickerView.userInteractionEnabled=YES;
    self.pickerView.delegate = self;
    self.pickerView.dataSource = self;
    [self.actionSheet addSubview:self.pickerView];

    UIToolbar *controlToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, dateSheet.bounds.size.width, 44)];

    [controlToolBar setBarStyle:UIBarStyleBlack];
    [controlToolBar sizeToFit];

    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    UIBarButtonItem * setButton = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleDone target:self action:@selector(dismissDateSet)];
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelButton)];

    [controlToolBar setItems:[NSArray arrayWithObjects:spacer, cancelButton, setButton, nil] animated:NO];

    [self.actionSheet showInView:[UIApplication sharedApplication].keyWindow];
    [self.actionSheet addSubview:controlToolBar];
    [self.actionSheet showInView:self.view];
    [self.actionSheet setBounds:CGRectMake(0 ,  20 , 320, 485)];

更多信息,您可以转到此处的参考链接

2)您可以将子视图放在UIPopview控制器上。
在这里对 UIPopovercontroller 中的 UIPickerview 提出同样的问题。

感谢和问候,

塞缪尔。

Hello Ur's Truly Prasad,

Better way to implement UIPickerView for that the there is two way to Display UIPicker view which is more prefrable

1) You can put subview over the UIAlertview
following code fot that.

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

    [self.actionSheet setActionSheetStyle:UIActionSheetStyleBlackTranslucent];

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

    self.pickerView = [[UIPickerView alloc] initWithFrame:pickerFrame];

    self.pickerView.showsSelectionIndicator = YES;
    self.pickerView.userInteractionEnabled=YES;
    self.pickerView.delegate = self;
    self.pickerView.dataSource = self;
    [self.actionSheet addSubview:self.pickerView];

    UIToolbar *controlToolBar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, dateSheet.bounds.size.width, 44)];

    [controlToolBar setBarStyle:UIBarStyleBlack];
    [controlToolBar sizeToFit];

    UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];

    UIBarButtonItem * setButton = [[UIBarButtonItem alloc] initWithTitle:@"Set" style:UIBarButtonItemStyleDone target:self action:@selector(dismissDateSet)];
    UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:@"cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelButton)];

    [controlToolBar setItems:[NSArray arrayWithObjects:spacer, cancelButton, setButton, nil] animated:NO];

    [self.actionSheet showInView:[UIApplication sharedApplication].keyWindow];
    [self.actionSheet addSubview:controlToolBar];
    [self.actionSheet showInView:self.view];
    [self.actionSheet setBounds:CGRectMake(0 ,  20 , 320, 485)];

More that you can go to refrence link here

2) You can put subview over the UIPopview controller.
and same question for the UIPickerview inside into UIPopovercontroller here.

Thanks and Regards,

Samuel.

从﹋此江山别 2025-01-12 22:33:56

问题解决了..
- 通过取消选中属性检查器中的“自动调整子视图大小”。
在界面生成器中

Problem solved..
- By Un check the 'Auto Resize Subview' in attribute inspector.
In Interface Builder

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文