How do I adjust my popover to the size of the content in my tableview in swift?

后端 未结 6 1099
情话喂你
情话喂你 2021-01-31 03:17

I\'m using popoverPresentationController to show my popover. The UITableViewController used to show as popover is created programmatically and will usu

6条回答
  •  日久生厌
    2021-01-31 03:23

    First thing first: All comments are good and help full. I have did little change in my logic which makes my VC as reusable component.

    Calling this method inside viewWillAppear:(BOOL)animated:

    -(void) setPopOverPreferedContentHeight {
    
         if (self.popoverPresentationController && self.tableView.contentSize.height < MAX_POPOVER_HEIGHT) {
              self.preferredContentSize=self.tableView.contentSize;
         } else if (self.popoverPresentationController){
             self.preferredContentSize = CGSizeMake(self.tableView.contentSize.width, MAX_POPOVER_HEIGHT);
       }
    }
    

提交回复
热议问题