How to Change image on UILongPressGestureRecognizer?
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...
}
精彩评论