如何更改 UILongPressGestureRecognizer 上的图像?

发布于 2024-12-06 18:20:40 字数 812 浏览 4 评论 0原文

我正在为Iphone开发短信应用程序.. 现在我想在长按时更改聊天气泡的图像(就像我复制内容时一样)..

我有这个代码..

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

我只想在长按它进行复制时将我的聊天气泡颜色更改为蓝色.. 就像iPhone默认所做的那样,我想做同样的事情......任何人都可以帮助我......

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

秋心╮凉 2024-12-13 18:20:40

看来您必须检查状态是否为UIGestureRecognizerStateRecognized才能更改聊天气泡的颜色,

if (longPressRecognizer.state == UIGestureRecognizerStateRecognized) {

    // Change Chat bubble's color to blue
}

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
}
甜中书 2024-12-13 18:20:40

当长按手势开始条件时检查颜色为红色

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

   } 

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

   } 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文