How to display the UITableView programmatically?

前端 未结 4 1221
温柔的废话
温柔的废话 2020-12-13 14:15

I want to ask a question about the UITableView of the objective C. I am writing a program and I would like to create the UI programmatically. However, I don\'t know how to d

4条回答
  •  醉酒成梦
    2020-12-13 14:48

    Something like this should do the trick (assuming this is running from within your view controller and you have a property set up for the table view):

    tableView = [[[UITableView alloc] initWithFrame:CGRectMake(...) style:UITableViewStylePlain] autorelease];
    tableView.dataSource = self;
    tableView.delegate = self;
    
    [self.view addSubview:tableView];
    

    Where you replace CGRectMake(...) with whatever position / size you'd like.

提交回复
热议问题