Image on top of Cell

前端 未结 4 926
挽巷
挽巷 2021-01-22 13:16

Can i put an image in the top of an TableViewCell instead of putting it on the left side ? I used this to put it in the cell:

Code:

<
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-22 13:46

    You can create a custom cell. You just pick style custom for the cell type. If you are using static cells you can just insert an ImageView in the cell, drag an outlet to the controller header file and set the image in the code.

    If you are using dynamic cells its best to create a new class for your cells. Set the custom class for the cell in the interface builder. Create and outlet for the imageview in the custom cell class header. Then when you instantiate cells in the tableView:cellForRowAtIndexPath, set the cell class to the custom cell class and set its property.

    There are very good tutorials for storyboards that cover dynamic and static cell tables:
    Beginning Storyboards in iOS Part 1
    Beginning Storyboards in iOS Part 2

提交回复
热议问题