2011-09-28 47 views
0

我正在为iPhone .. SMS应用,现在我想在长按改变我的聊天泡泡的图像(如,而我复制含量的不同)..如何更改UILongPressGestureRecognizer上的图像?

我有这样的代码..

if (longPressRecognizer.state == UIGestureRecognizerStateBegan) 
    { 


     [self becomeFirstResponder]; 

     //NSIndexPath *pressedIndexPath = [tblOutgoingMessagesRecords indexPathForRowAtPoint:[longPressRecognizer locationInView:tblOutgoingMessagesRecords]]; 

     NSIndexPath *pressedIndexPath = [tblOutgoingMessagesRecords indexPathForCell:(UITableViewCell *)longPressRecognizer.view]; 
     if (pressedIndexPath && (pressedIndexPath.row != NSNotFound) && (pressedIndexPath.section != NSNotFound)) 
     { 
      [self becomeFirstResponder]; 
      NSLog(@" Presssed on Copy "); 

我只是想改变我的聊天气泡的颜色为蓝色,而我在iPhone默认做我想做的事情一样......任何一个可以帮助我lonpress它拷贝.. 像...

回答

2

看来你必须检查状态UIGestureRecognizerStateRecognized更改聊天气泡的颜色,

if (longPressRecognizer.state == UIGestureRecognizerStateRecognized) { 

    // Change Chat bubble's color to blue 
} 
+0

怎么样?米使用图像的聊天气泡..我想更换onhold(长按)..所以我怎么办? – Vivek2012

1

检查颜色为红色时长按手势开始条件

if (longPressRecognizer.state == UIGestureRecognizerStateBegan) 
{ 


    [self becomeFirstResponder]; 
    // change image from here 
    //NSIndexPath *pressedIndexPath = [tblOutgoingMessagesRecords indexPathForRowAtPoint:[longPressRecognizer locationInView:tblOutgoingMessagesRecords]]; 

    NSIndexPath *pressedIndexPath = [tblOutgoingMessagesRecords indexPathForCell:(UITableViewCell *)longPressRecognizer.view]; 
    if (pressedIndexPath && (pressedIndexPath.row != NSNotFound) && (pressedIndexPath.section != NSNotFound)) 
    { 
     [self becomeFirstResponder]; 
     NSLog(@" Presssed on Copy "); 
    } 
} 
else if (longPressRecognizer.state == UIGestureRecognizerStateChanged) 
{ 

    //load original image here... 

    } 
+0

其不工作的朋友...!它认识到它的副本,但图像没有改变..我怎么能改变图像在其他如果.. – Vivek2012