Sup*_*off 4 string objective-c uitableview ios
我有一个带CustomCell的UITableView.自定义单元格包含UILabel和UIImageView.
我在网上看到,当用户按下单元格时,可以从普通的UITableView单元格中获取文本并将其存储在字符串中.
但是,当您使用自定义单元格时,如何执行此操作?因为我的UILabel的名称是"type_label",它已经在我的CustomCell XIB的头文件中定义.
所以在Xcode中我无法使用:
cell.type_label.text"
Run Code Online (Sandbox Code Playgroud)
在以下功能中:
-(void)tableView:(UITableView *) tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
Run Code Online (Sandbox Code Playgroud)
谢谢,丹.
CW0*_*007 12
在tableViewDidSelectRow中,您需要做的就是:
UITableViewCellCustomClass *customCell = (UITableViewVellCustomClass*)[tableView cellForRowAtIndexPath:indexPath];
NSString *labelText = [[customCell type_label] text];
Run Code Online (Sandbox Code Playgroud)
这应该让你想要你需要.
| 归档时间: |
|
| 查看次数: |
9009 次 |
| 最近记录: |