简体   繁体   English

如何在UILongPressGestureRecognizer上更改图像?

[英]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.

相关问题 UILongPressGestureRecognizer如何将当前视图更改为另一个视图控制器? - how can a UILongPressGestureRecognizer change the present view to another View Controller? 如何使UIPanGestureRecognizer的UILongPressGestureRecognizer失败? - how to fail UILongPressGestureRecognizer for UIPanGestureRecognizer? 如何将UILongPressGestureRecognizer添加到UITextField? - How to add a UILongPressGestureRecognizer to a UITextField? 如何将UILongPressGestureRecognizer添加到UITextField? - How to add UILongPressGestureRecognizer to a UITextField? UILongPressGestureRecognizer - UILongPressGestureRecognizer 在editmode中如何在UITableViewCell上暂停/禁用UILongPressGestureRecognizer - How to pause/disable UILongPressGestureRecognizer on a UITableViewCell while in editmode 在 UILongPressGestureRecognizer 之后如何识别在视图上按下了哪个按钮 - How to recognize which button is pressed on the view after an UILongPressGestureRecognizer iPhone iOS如何将UILongPressGestureRecognizer和UITapGestureRecognizer添加到同一控件并防止冲突? - iPhone iOS how to add a UILongPressGestureRecognizer and UITapGestureRecognizer to the same control and prevent conflict? UILongPressGestureRecognizer无法正常工作 - UILongPressGestureRecognizer not working UILongPressGestureRecognizer无法正常工作 - UILongPressGestureRecognizer is not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM