【问题标题】:Controlling Location of Popover控制弹出框的位置
【发布时间】:2012-04-15 23:55:15
【问题描述】:

我的 MainViewController 上有一个 Add UIButton,它加载了一个弹出框。即使“添加”按钮位于最右侧,我也希望弹出框在加载时居中。 iPad 应用程序 (iOS 5.1) 的唯一视图将是横向。我删除了方向箭头。

我试过@property (nonatomic, readwrite) UIEdgeInsets popoverLayoutMargins;但我不知道如何使用它进行编码。

我也遇到了 presentPopoverFromRect:CGRectMake(x,y,w,h)],但没有运气。

如有必要,我可以包含代码。

感谢您的帮助。

【问题讨论】:

    标签: ipad ios5 popover


    【解决方案1】:

    以下代码将弹出框置于屏幕顶部的 x 轴中心。如果您还想以 y 轴为中心,请使用 self.view.frame.height/2 作为 CGRectMake 中的第二个参数。

        [_myPopover presentPopoverFromRect:CGRectMake(self.view.frame.size.width/2 ,0,1,1)
                                         inView:self.view
                       permittedArrowDirections:UIPopoverArrowDirectionAny
                                       animated:YES];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-10-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多