2011-09-28 37 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