Jac*_*son 0 objective-c uitableview ios
我在表视图单元格view1和view2上有2个视图,我想要做的是当我点击一个单元格时我希望隐藏view1并显示view2(在开始时显示view1并隐藏view2),我使用了视图view1 = 102和view2 = 103的标签,由于某些原因我无法想象,view1被隐藏但是view2没有显示.
这是我的代码:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
UIView * view1 = (UIView *)[cell viewWithTag:102];
UIView * view2 = (UIView *)[cell viewWithTag:103];
[view1 setHidden:YES];
[view2 setHidden:NO];
NSLog(@"View 2 is : %hhd",view2.hidden);
}
Run Code Online (Sandbox Code Playgroud)
故事板
模拟器
Jea*_*Luc 10
代替
cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)
使用
cell = [tableView cellForRowAtIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)
因为dequeueReusableCellWithIdentifier: forIndexPath:
将返回当前不可见的当前未使用的表格单元格.
归档时间: |
|
查看次数: |
1253 次 |
最近记录: |