访问UITableView部分标题中的UI元素 [英] Access UI elements in UITableView section header

查看:93
本文介绍了访问UITableView部分标题中的UI元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在此帖后为我的 UITableView 创建了一个标题部分: https: //stackoverflow.com/a/11396643/1568886 。我现在遇到的问题是访问单元格中的按钮和标签。当我连接按钮和标签作为出口到TableViewController Xcode时抛出一个错误:

I created a header section for my UITableView following this post: https://stackoverflow.com/a/11396643/1568886. The issue I'm having now is accessing the buttons and label within the cell. When I connect the button and labels as outlets to the TableViewController Xcode throws an error:

/Users/ericky/Desktop/sample/sample-master/sample/en.lproj/MainStoryboard.storyboard: Couldn't compile connection: <IBCocoaTouchOutletConnection:0x7f8005e14430  <IBProxyObject: 0x7f8005e18260> => userProfileImage => <IBUIImageView: 0x7f8005e0d640>>

我的观点如下:

< img src =https://i.stack.imgur.com/wcC75.pngalt =在此处输入图像说明>

如何访问用户界面单元格中的元素?

How do I access the UI elements within the cell?

推荐答案

您需要创建一个自定义UITableViewCell,为它创建一个类并将按钮和标签连接到您创建的类而不是TableViewController。我使用本教程学习如何操作:

You need to create a custom UITableViewCell, create a class for it and connect the buttons and labels to the class you created instead of the TableViewController. I used this tutorial to learn how to do it:

http://www.appcoda.com/customize-table-view-cells-for-uitableview/

这篇关于访问UITableView部分标题中的UI元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆