0
我目前正在使用ChatScreen,並且想添加Archive功能。如何使用UILongPressGestureRecognizer獲得Selected TableView Cell的框架
我的TableView
現在有兩個單元格。
我將LongPressGesture
添加到打開視圖中。
CGRect myRect = [tblView rectForRowAtIndexPath:indexPath];
UILongPressGestureRecognizer *lpgr = [[UILongPressGestureRecognizer alloc]
initWithTarget:self action:@selector(handleLongPressReceiverText:)];
lpgr.minimumPressDuration = 2.0;
lpgr.delegate = self;
myRect = [tblView rectForRowAtIndexPath:indexPath];
[cell.contentView addGestureRecognizer:lpgr];
這是長按手勢實現
- (void) handleLongPressReceiverText: (UILongPressGestureRecognizer *)recognizer {
if (recognizer.state == UIGestureRecognizerStateBegan) {
CGPoint p = [lpgr locationInView:tblView];
NSLog(@"%f",p.x);
_ReceivertextView.frame = CGRectMake(p.x,p.y,_ReceivertextView.frame.size.width, 40);
[self.view addSubview: self.ReceivertextView];
[self.view bringSubviewToFront: self.ReceivertextView];
}
if (recognizer.state == UIGestureRecognizerStateEnded)
{
NSLog(@"longTouch UIGestureRecognizerStateEnded");
}
}
我想獲得一個特定的細胞,這是我用LongPressGesture
竊聽的確切位置。
任何幫助,這是高度讚賞。
是查看在細胞的indexpath.but顯示,當我滾動cell.it保持在同一indexpath.not改變 –
@DivineChild你需要管理的的UIView的框架使用tableview委託方法'scrollViewDidScroll'。 – Mahesh