我在 UITableView 的自定义单元格中有一个 UIButton 在拖动该按钮时我必须在单元格中打开另一个视图,该视图最初位于单元格的最右角的自定义单元格中...
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
RecentCell *cell = (RecentCell*)[_tableView dequeueReusableCellWithIdentifier: [NSString stringWithFormat:@"%d-%d",indexPath.section,indexPath.row]];
if (cell == nil) {
cell = [[[NSBundle mainBundle] loadNibNamed:@"RecentCell" owner:self options:nil] lastObject];
}
[cell.TestButton addTarget:self action:@selector(ViewMovedTouchDragInside:withEvent:) forControlEvents:UIControlEventTouchDragInside];
return cell;
}
并且在拖动按钮时调用此方法
- (IBAction) ViewMovedTouchDragInside:(id) sender withEvent:(UIEvent *) event
{
UIControl *control = sender;
UITouch *t = [[event allTouches] anyObject];
CGPoint pPrev = [t previousLocationInView:control];
CGPoint p = [t locationInView:control];
CGPoint center = control.center;
center.x += p.x - pPrev.x;
CGPoint hitPoint = [sender convertPoint:CGPointZero toView:self.tableView];
NSIndexPath *hitIndex = [self.tableView indexPathForRowAtPoint:hitPoint];
RecentCell * swipedCell = (RecentCell*)[self.tableView cellForRowAtIndexPath:hitIndex];
//Drag Button on left hand side
if (control.frame.origin.x<0) {
swipedCell.MessageView.Frame=CGRectMake(320.0+control.frame.origin.x,0,control.frame.origin.x,swipedCell.MessageView.frame.size.height);
NSLog(@"*****%f*****%f****%f****%f",swipedCell.MessageView.frame.origin.x,swipedCell.MessageView.frame.origin.y,swipedCell.MessageView.frame.size.width,swipedCell.MessageView.frame.size.height);
}
else{
swipedCell.CallImage.frame=CGRectMake(0.0,0,control.frame.origin.x,cell.CallImage.frame.size .height);
}
}
橙色图像正常工作但蓝色图像视图框架变为零...
请建议我该怎么做...