[英]How to Change image on UILongPressGestureRecognizer?
I am working on SMS application for Iphone .. And now i want to change image of my chat bubble on longpress ( like while i copy the contant ).. 我正在为Iphone开发SMS应用程序。.现在,我想在longpress上更改聊天气泡的图像(就像我复制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 ... 我只想将聊天气泡颜色更改为蓝色,而我按住loncopy以进行复制..就像在iPhone中默认操作一样,我也想做同样的事情...有人可以帮我吗...
It seems you have to check if the state is UIGestureRecognizerStateRecognized to change the Chat bubble's color, 似乎您必须检查状态是否为UIGestureRecognizerStateRecognized才能更改聊天气泡的颜色,
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...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.