Ios SWTableViewCell幻灯片以编程方式
如何以编程方式滑动SWTableViewCellIos SWTableViewCell幻灯片以编程方式,ios,objective-c,uitableview,slide,Ios,Objective C,Uitableview,Slide,如何以编程方式滑动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]; 在
//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];
}
}
但这是不正确的。你能帮我吗
谢谢,
Mikel我希望在选择表视图单元格时能够显示实用程序按钮,因此我在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];
}
我对你的代码有问题。当选择了表格视图单元格但该单元格滚动两次时,我显示了实用程序按钮。我在单元格左侧有一个图像,当我选择单元格时,有时会很好地滚动,我会看到右侧的图像,但有时会滚动两次,我必须单击两次才能关闭单元格。你知道发生了什么事吗?谢谢你。我想我应该说,在我的情况下,我只有按钮在单元格的左侧,而不是右侧。如果不尝试任何东西,我猜设置细胞状态与你看到的行为有关。您可能需要添加代码来确定当前scrollView contentOffset,然后再将其设置为显示一侧或另一侧的按钮。