【问题标题】:Displaying UItableViewController inside UIPopoverController在 UIPopoverController 中显示 UItableViewController
【发布时间】:2011-08-17 11:46:46
【问题描述】:

我在 UIPopoverController 中显示 UITableViewController。一切正常,即使 TableViewController 的大小非常大,即使只有 3-4 个单元格。如何使弹出框控制器的高度与 tableview 的高度完全相同?

【问题讨论】:

    标签: objective-c cocoa-touch ipad uitableview uipopovercontroller


    【解决方案1】:

    您可以使用UIPopoverController 的方法- (void)setPopoverContentSize:(CGSize)size animated:(BOOL)animated 或使用UIViewController @property(nonatomic, readwrite) CGSize contentSizeForViewInPopover 上的属性来实现此目的。

    【讨论】:

      【解决方案2】:

      像这样覆盖UITableViewControllercontentSizeForViewInPopover

      - (CGSize)contentSizeForViewInPopover {
          // Currently no way to obtain the width dynamically before viewWillAppear.
          CGFloat width = 200.0; 
          CGRect rect = [self.tableView rectForSection:[self.tableView numberOfSections] - 1];
          CGFloat height = CGRectGetMaxY(rect);
          return (CGSize){width, height};
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多