Moving a View table to another view in a UITableViewController

I am trying to resize a table view of a UITableViewController so that I can also add other content to the view. Therefore, I am trying to change the table in a new view. The following works, but if I try to reference self.tableview later, it returns null. What am I doing wrong?

- (void) viewDidLoad {
    [super viewDidLoad];

    UIView * view = [[UIView alloc] initWithFrame: [UIScreen mainScreen] .applicationFrame]; 
    self.tableView.frame = CGRectMake (0, 0, 320, 200);
    [view addSubview: self.tableView];
    self.view = view;
}

Yes, I can probably just use the UIViewController and create my own table view there. I was just trying to avoid this if I can, and get the free version of UITableViewController

+3
source share
1 answer

To get around the problem, I just held onto the View table and overwrite the tableview getter

- (UITableView *) tableView {
    return myTableView;
}

- (void) viewDidLoad {
    [super viewDidLoad];
    myTableView = [super tableView];
    UIView * view = [[UIView alloc] initWithFrame: [UIScreen mainScreen] .applicationFrame]; 
    self.view = view;
    myTableView.frame = CGRectMake (0, 0, 320, 200);
    [view addSubview: myTableView];
    }
+1
source

Source: https://habr.com/ru/post/1710123/


All Articles