我在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);
}
}
橙色图像正常工作但是蓝色图像视图框正在变为零......
请告诉我如何做到这一点...