Creating a UITableViewController programmatically

前端 未结 4 781
逝去的感伤
逝去的感伤 2020-12-30 17:44

This is what I tried. Nothing appears on the screen and none of the UITableView methods that you are supposed to implement are getting called.

-(void)loadVie         


        
4条回答
  •  被撕碎了的回忆
    2020-12-30 18:48

    Make sure you set the delegate of TVC, with

    TVC.delegate = self;
    

    That's the reason why none of those methods are getting called. Also, make sure your class implements the UITableViewDelegate protocol by changing your interface declaration to

    @interface YourViewController : UIViewController  {
        //declare variables here
    }
    

    Also, equally important, don't set TVC.view, as this already happens when you initialize the view controller. You're just setting it to a blank view, which is why you're not seeing anything.

提交回复
热议问题