小编MrD*_*rDB的帖子

手势问题:UISwipeGestureRecognizer + UISlider

有手势相关的问题.我实现了UISwipeGestureRecognizer以获得向左和向右滑动事件,并且工作正常.然而,我面临的问题是我在同一视图中的UISlider不是很好玩.滑块的滑动被误认为是向左/向右滑动.

以前有人遇到过这个问题,有什么想法可以纠正吗?

非常感谢.

以下是视图控制器中包含的代码:

 - (void)viewDidLoad {

            [super viewDidLoad];

                //Setup handling of LEFT and RIGHT swipes
             UISwipeGestureRecognizer *recognizer;

                recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
                [recognizer setDirection:(UISwipeGestureRecognizerDirectionRight)];
                [[self view] addGestureRecognizer:recognizer];
                [recognizer release];

                recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeFrom:)];
                [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)];
                [[self view] addGestureRecognizer:recognizer];
                [recognizer release];
        }

    -(void)handleSwipeFrom:(UISwipeGestureRecognizer *)recognizer {

      if (recognizer.direction == UISwipeGestureRecognizerDirectionRight) {
       NSLog(@"Swipe Right");
       //Do stuff
      }

      if (recognizer.direction == UISwipeGestureRecognizerDirectionLeft) {
       NSLog(@"Swipe Left");
       //Do stuff
      }
    }
Run Code Online (Sandbox Code Playgroud)

iphone event-handling gesture-recognition uislider uigesturerecognizer

23
推荐指数
1
解决办法
8769
查看次数

径向渐变绘制性能 - OpenGL-ES可以改进吗?

我正在开发一个图像处理应用程序,它覆盖了从照片库加载的图像上的径向渐变.

在屏幕上我有一个滑块来动态地/减少径向渐变的半径.我发现在模拟器上的性能还不错,但在iPhone 3G或3GS上,移动滑块时重绘速度慢得多.

我目前正在CGContextDrawRadialGradient用于绘画.我每次重绘的步骤都是:

  1. 创建图形上下文:UIGraphicsBeginImageContext(size);
  2. 创建渐变对象: CGGradientCreateWithColorComponents
  3. 将图像(从照片库加载的照片)绘制到屏幕比例: drawInRect
  4. 设置为叠加混合模式: CGContextSetBlendMode
  5. 绘制渐变: CGContextDrawRadialGradient
  6. 使用UIGraphicsGetImageFromCurrentImageContext()创建UIimage;
  7. UIGraphicsEndImageContext();
  8. 将完成的图像绘制到屏幕:drawInRect.

是否有更快的绘制方式?也许使用OpenGL?

任何建议/示例代码将不胜感激.

谢谢.

iphone opengl-es ios4 ios

7
推荐指数
1
解决办法
2195
查看次数

DD-WRT嵌入式路由器上的Python脚本

我编写了两个Python(2.x)脚本来执行以下操作:

  1. 自定义代理服务器(导入optparse,ConfigParser,TLDextract,SocketServer ......)
  2. 代理的Web管理员(进口烧瓶,ConfigParser,netifaces ......)

这些目前都在Raspberry pi(Raspian)上运行,但我正在寻求一些关于如何在DDWRT路由器(v24)上运行这些选项的建议.

我的想法是:

  1. 在DDWRT上安装python和必需的库.虽然我发现一些证据表明python可以通过ipkg安装(在USB存储器上)但我不清楚如何安装所需的导入库?

  2. 创建一个独立于python的二进制文件(例如PyInstaller)以在DDWRT上运行.我有犹豫不决,因为我想我需要在运行Python的DDWRT上执行任务(即回到思想1),以及它如何处理导入的库?

  3. 与第1点类似:编译包含所有必需Python包的自定义OpenWRT映像.这似乎是一项复杂的工作.

感谢您的任何建议.

python openwrt pyinstaller dd-wrt

6
推荐指数
1
解决办法
8838
查看次数

动态内存/重新分配字符串数组

希望创建一个字符串值的动态数组。

在下面的示例代码中,目的是在运行时添加一个新的数组项(realloc)和一个新的字符串(“string 3”)。

我想问题是指针使用不当和/或 realloc 逻辑有问题?

感谢任何帮助。

我得到的实际输出:

Before: 
Array[0]: string 1
Array[1]: string 2
After: 
Array[0]: string 1
Array[1]: string 2
Run Code Online (Sandbox Code Playgroud)

编码:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

char **myArray;

main(int argc, char *argv[])
{
    int i = 0;
    myArray = malloc(2 * sizeof(char*));
    int arrayIndexs = sizeof(*myArray) / sizeof(char*);

    //Allocate memory for each [x]
    for (i = 0; i <= arrayIndexs; i++)
        myArray[i] = malloc(254 * sizeof(char*));
    //Populate initial values
    if(myArray != NULL)
    {
        strcpy(myArray[0], "string 1");
        strcpy(myArray[1], …
Run Code Online (Sandbox Code Playgroud)

c memory arrays

5
推荐指数
1
解决办法
2万
查看次数