【发布时间】:2015-08-04 10:13:57
【问题描述】:
在我的UITableView 中,我有不同的控件,例如UIImage、UILabel...当我单击UILabel 时,必须突出显示文本的颜色。任何人都可以帮助我吗?这是下面的代码。
UITapGestureRecognizer* gesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(UserNameClick:)];
[cell.usrName setUserInteractionEnabled:YES];
[cell.usrName addGestureRecognizer:gesture];
cell.usrName.tag=indexPath.row;
- (IBAction)UserNameClick:(id)sender
{
UITapGestureRecognizer *tapRecognizer = (UITapGestureRecognizer *)sender;
NSString *strUserID,*strUsername;
NSDictionary *dictionary = [self.allPostArray objectAtIndex:[tapRecognizer.view tag]];
}
【问题讨论】:
-
要显示 UITableView 元素的变化,你必须重新加载 tableview。因此,您必须在“cellForRowAtIndexPath”中设置标签颜色更改,并且您还必须保存最后选择/当前选择的索引才能在 tableview 中获得所需的更改..
-
不用轻拍也可以
-
我还为您发布了我的工作演示应用程序代码
-
Subramanian Raj 将按钮放在表格视图上,并在单击按钮或单元格时更改背景颜色..
标签: ios xcode uitableview uilabel