Show custom label when no data available for tableView

后端 未结 2 2147
误落风尘
误落风尘 2021-02-14 18:24

The app in question has an ability for users to mark items as favourite. When the user has no favourites saved, I\'d like to notify them of the fact (mostly I hate the idea of

2条回答
  •  滥情空心
    2021-02-14 19:03

    What I personally would do is the following. As you said yourself, in the method numberOfRowsInSection you should check the count of your tableView datasource, if its 0 you should return 1 in order to display the 1 cell ou want.

    Then in cellForRowAtIndexPath you should check the count again, if it returns 0 you know that the table view is trying to draw your "You currently have no favorites" and you can set the text.

提交回复
热议问题