Using a UITableViewController with a small-sized table?

后端 未结 11 1167
一生所求
一生所求 2020-12-31 05:51

When using a UITableViewController, the initWithStyle: method automatically creates the underlying UITableView with - according to the documentation - \"the correct dimensio

相关标签:
11条回答
  • 2020-12-31 06:37

    I had the same problem and I solved it with:

    -(void) loadView {
        [self setView:[[[UIView alloc] initWithFrame:CGRectZero] autorelease]];
        [[self view] setAutoresizesSubviews:NO];
    
        /* Create & configure table and other views... */
    
        [self setResultsTable:[[RadarTableViewController alloc] initWithNibName:nil bundle:nil]];
        [[resultsTable view] setFrame:CGRectMake(0,45,320,200)];
    }
    

    This is done in the parent (just a plain UIViewController in my case) controller.

    0 讨论(0)
  • 2020-12-31 06:38

    Set the frame in UINavigationController.

    0 讨论(0)
  • 2020-12-31 06:39

    You can set the top margin by using :

        UIEdgeInsets inset = UIEdgeInsetsMake(50, 0, 0, 0);
        self.tableView.contentInset = inset;
    

    it's Not a good practice , just in case you want more space on top you can use it .

    Should not use UITableViewController , Just simply Use UIViewController and Programmatically Create UITableview

    0 讨论(0)
  • 2020-12-31 06:44

    I agree with Ben's answer. I've often run into the situation where I need to resize a UITableVIew due to other controls on a view.

    I usually just have a regular UIViewController with a UITableView IBOutlet. Then, if I need to, I can just manipulate the UITableView object's frame to get it to the size I need.

    0 讨论(0)
  • 2020-12-31 06:44

    If you are using Interface Builder, you can simply go to "Table View Size" properties window, and change Bottom Insets for both Content and Scroller with the height of another widget.

    0 讨论(0)
提交回复
热议问题