开发者

How to Change image on UILongPressGestureRecognizer?

开发者 https://www.devze.com 2023-04-09 10:59 出处:网络
I am working on SMS application for Iphone .. And n开发者_如何学JAVAow i want to change image of my chat bubble on longpress ( like while i copy the contant )..

I am working on SMS application for Iphone .. And n开发者_如何学JAVAow i want to change image of my chat bubble on longpress ( like while i copy the contant )..

i have this code ..

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

I just want to change my Chat bubble color to blue while i lonpress it for copy .. As like in iphone default has done i want to do same ... Can any one help me ...


It seems you have to check if the state is UIGestureRecognizerStateRecognized to change the Chat bubble's color,

if (longPressRecognizer.state == UIGestureRecognizerStateRecognized) {

    // Change Chat bubble's color to blue
}


check color to red when long press gesture begin condition

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

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号