在视图控制器中显示带有图像和标签的标题视图
我是 iPhone 开发新手。我创建了一个视图控制器,并使用了分组表视图。现在我想在我的视图控制器中显示带有图像和标签的标题视图。请指导我并帮助我解决这个问题。
谢谢。
I am new to iPhone development. I have created one view controller and I used grouped table view. Now I want to display the header view in my viewcontroller with image and labels. Please guide me and help me out in this problem.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你是指 headerView 还是sectionHeaderView?您可以在
viewDidLoad
方法中将子视图添加到 headerView:您可以使用
initWithFrame
方法指定标签的大小和位置,并将标签作为子视图添加到 tableHeaderView - 您可以用多个标签来做到这一点。如果您指的是sectionHeader,则必须实现
tableView:viewForHeaderInSection:
方法,您必须在其中创建一个新视图,并向其添加不同的子视图:在这种情况下,您还必须实现该方法< code>tableView:heightForHeaderInSection: 必须返回您在上述方法中创建的视图的高度:
Do you mean a headerView or a sectionHeaderView? You can add subviews to the headerView in the
viewDidLoad
method:You specify size and position of the label with the
initWithFrame
method, and add the label as subview to the tableHeaderView - you can do this with multiple labels.If you mean the sectionHeader you have to implement the
tableView:viewForHeaderInSection:
method, where you have to create a new view, and add different subviews to it:In this case you also have to implement the method
tableView:heightForHeaderInSection:
which has to return the height of the view you create in the above method: