簡體   English   中英

如何在UILongPressGestureRecognizer上更改圖像?

[英]How to Change image on UILongPressGestureRecognizer?

我正在為Iphone開發SMS應用程序。.現在,我想在longpress上更改聊天氣泡的圖像(就像我復制contant一樣)。

我有這個代碼..

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 ");

我只想將聊天氣泡顏色更改為藍色,而我按住loncopy以進行復制..就像在iPhone中默認操作一樣,我也想做同樣的事情...有人可以幫我嗎...

似乎您必須檢查狀態是否為UIGestureRecognizerStateRecognized才能更改聊天氣泡的顏色,

if (longPressRecognizer.state == UIGestureRecognizerStateRecognized) {

    // Change Chat bubble's color to blue
}

長按手勢開始時將顏色檢查為紅色

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...

   } 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM