iOS: can not create custom view on UITableViewController

前端 未结 2 1066
耶瑟儿~
耶瑟儿~ 2021-01-28 17:01

What am I doing?
I am learning iOS by building an app. My requirement shows some transactions on UITableViewController

I

2条回答
  •  盖世英雄少女心
    2021-01-28 17:58

    Use a UIViewController rather than a UITableViewController

    I recommend you don't use a UITableViewController as there's little advantage as far as I can see, whilst custom views like you're looking for are unnecessarily difficult.

    Use a UIViewController and pull a UITableView object (Within the interface builder) on to that view. You can size and position it anywhere you like.

    Remember to include the delegates within the header file, like below, and to connect the UITableView object delegate to the the viewController.

    @interface ViewController: UIViewController
    

    Screenshot below of a UIViewController within the interface builder and I've added a UITableview object (which is greyed out here) and added a UIView at the top (coloured brown so you can see it clearly).

    This of course is just an example, but hope it helps you get the idea.

    enter image description here

    Although in the above screen shot I'm using storyboard, though you can do this just the same with a Xib too.

    I hope this helps.

提交回复
热议问题