我如何以编程方式滑动 SWTableViewCell。
//When i click in a cell i want to open the swtableviewcell
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
???
}
我试过:
[[[SWTableViewCell alloc]init]didTransitionToState:2];
在 swtableviewcell.m 中
-(void)didTransitionToState:(UITableViewCellStateMask)state{
NSLog(@"state: %lu",state);
if (_cellState == kCellStateCenter)
{
[self.cellScrollView setContentOffset:[self contentOffsetForCellState:kCellStateRight] animated:YES];
[self.delegate swipeableTableViewCell:self scrollingToState:kCellStateRight];
}
但不正确。你能帮帮我吗?
谢谢, 米克尔
最佳答案
我希望能够在选择表格 View 单元格时显示实用程序按钮,因此我在 SWTableViewCell.m 中添加了一个方法
-(void)showUtilityButtonsAnimated:(BOOL)animated {
// Force the scroll back to run on the main thread because of weird scroll view bugs
dispatch_async(dispatch_get_main_queue(), ^{
[self.cellScrollView setContentOffset:CGPointMake(0, 0) animated:YES];
});
_cellState = kCellStateLeft;
if ([self.delegate respondsToSelector:@selector(swipeableTableViewCell:scrollingToState:)])
{
[self.delegate swipeableTableViewCell:self scrollingToState:kCellStateCenter];
}
不要忘记将它添加到 SWTableViewCell.h
- (void)showUtilityButtonsAnimated:(BOOL)animated;
然后从您的 -tableView:didSelectRowAtIndexPath: 委托(delegate)方法中调用该方法。例如:
if (indexPath.row == 0) {
SWTableViewCell *cell = (SWTableViewCell *)[self.tableView cellForRowAtIndexPath:indexPath];
[cell showUtilityButtonsAnimated:YES];
}
关于ios - SWTableViewCell 以编程方式滑动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25891110/