基本上我想隐藏总是隐藏 uiview(带按钮),直到一个单元格被触摸然后它从单元格底部带动画(如果可能)调出 uiview
像这样:
我在一个应用程序中看到了这一点并爱上了它,并认为这将是很棒的用户体验。
请问我该如何存档,干杯
到目前为止的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *mycell=[tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
if (mycell==nil) {
mycell=[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cellIdentifier"];
}
UIView *myview = [[UIView alloc] initWithFrame:CGRectMake(0, 25, 320, 50)];
[myview setBackgroundColor:[UIColor greenColor]];
[mycell.contentView addSubview:myview];
mycell.imageView.image = [UIImage imageNamed:@"placeholder.png"];
mycell.textLabel.text = @"Song Title";
UIFont *myFont = [ UIFont fontWithName: @"AppleSDGothicNeo-Bold" size: 12.0 ];
[mycell.textLabel setTextColor: [UIColor colorWithRed:0.839 green:0.271 blue:0.255 alpha:1]];
mycell.textLabel.font = myFont;
return mycell;
}
P.s myView 是我要添加的 View ,它将包含按钮。干杯!!!
最佳答案
此选项要求您的 UITableViewDelegate
和 UITableViewDataSource
是同一个对象,这通常是这种情况。
- 在
UITableViewDelegate
的tableView:didSelectRowAtIndexPath:
中,您可以管理一组选定的 indexPath 值,然后调用[tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone]]
用于刚刚选择/取消选择的行。 - 在
tableView:cellForRowAtIndexPath
中,您可以检查当前的 indexPath 是否在UITableViewDelegate
方法管理的选定 indexPath 列表中,并采取适当的操作来显示/隐藏附加内容
关于ios - 选择单元格时如何隐藏和显示 uiview UITableView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25072833/