IOS How to add a STATIC UITableView and another view to the same view controller

When I create a static table view and put it in a regular view controller, I get an error message that indicates that the table static views should be in the UITableViewController.

What I want is a look at the iPad, which has a static table view that takes up most of the screen, but below it is a standard UIView that always remains visible and has a couple of shortcuts that I update based on the content in a tabular view .

Is there a way to use the UITableViewController and have the tableView not full screen so that I can add a view in the storyboard to it?

If not, can this be done in code?

Any advice would be appreciated!

+5
source share
5 answers

The real answer is to create a custom container controller.

For example, you might have a view of a static table inside a navigation controller. Thus, you need to create a container class, for example, a navigation controller or whatever, and add a static table view controller to it.

0
source

, UITableViewController ( ), , , . Apple WWDC. ( UIDatePicker, ):

viewDidLoad . .

[self.tableView addSubview:self.datePicker];
[self updateDatePickerBounds];

scrollViewDidScroll, :

- (void) scrollViewDidScroll:(UIScrollView *)scrollView
{
    // Keep the date picker floating above the table view, anchored to the bottom of the view
    [self updateDatePickerBounds];
}

, :

- (void) updateDatePickerBounds
{
    // Keep the date picker floating above the table view, anchored at the bottom
    CGRect tableBounds = self.tableView.bounds;
    CGRect pickerFrame = self.datePicker.frame;
    pickerFrame = CGRectMake(tableBounds.origin.x,
                             tableBounds.origin.y + CGRectGetHeight(tableBounds) - CGRectGetHeight(pickerFrame),
                             tableBounds.size.width,
                             pickerFrame.size.height);
    self.datePicker.frame = pickerFrame;
}

, , , contentInset .

updateDatePickerBounds viewWillAppear. , .

+6

, , :

  • UIViewController, . BaseViewController ( , )
  • UITableViewController, . MyStaticTableViewController ( Storyboard )
  • Storyboard UIView BaseViewcontroller, . myStaticTableView.
  • MyStaticTableViewController myStaticTableView.
+2

, UITableViewController UITableView. , , tableFooterView UITableView. , UIView ( , , , ). , , , .

+1

Static TableView cells must be of type UITableViewController, but you can achieve the same effect using the ViewController with TableView (or 2) and take care of the cellForRowAtIndexPath method for the TV that you want to be a "Static cell". Just switch IndexPath.section and .row and create the cell the way you want it. Better encoding, but you get the same effect with more flexibility if you don't want to do this with Apple static cells.

+1
source

All Articles