IPhone应用程序缓慢使用phonegap
iphone app slow using phonegap
我使用phonegap开发了一个iphone/android绘图功能应用程序。在触摸开始和触摸移动时,应用程序可以在画布上绘制线条(Context)。在网上画画很慢。甚至应用程序的加载时间也很慢。(启动画面显示自己至少6-8秒。
www文件夹大小小于2MB。我们不加载复杂或沉重的图形。
我不太确定这是否是您的意思,但要使它以通常的方式绘制,这就是您的代码应该看起来像:
注意您可以更改上下文的设置。
@synthesize canvas, drawing; //Both UIImageViews
CGPoint touchPrev;
CGPoint touchLoc;
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
touchPrev = [touch locationInView:self.view];
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch * touch = [touches anyObject];
touchLoc = [touch locationInView:self.view];
UIGraphicsBeginImageContext(canvas.frame.size);
[canvas.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 8);
CGContextSetRGBStrokeColor(context, 0.8, 0, 0, 1);
CGContextSetLineCap(context, kCGLineCapRound);
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), touchLoc.x, touchLoc.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), touchPrev.x, touchPrev.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
canvas.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
touchPrev = touchLoc;
}
-(void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
touchPrev = touchLoc;
}
这是一个很难克服的限制。在网络技术上这样做必然会有这样的副作用。唯一的解决办法是在2D图形中这样做。
相关文章:
- 如何在android中使用phonegap将文件从一个文件夹移动/复制到另一个文件夹
- 对iPad上的点击事件反应缓慢
- Phonegap-(安卓/iphone)多个图像的图像库出现问题
- angular.js没有'无法在PhoneGap中处理视图标记
- 在phonegap应用程序内部重定向不起作用
- 压缩phonegap中ios的图像插件
- Ajax请求文档就绪会导致jquery加载缓慢
- 谷歌地图API v3不适用于移动浏览器或PhoneGap
- 尝试使用Phonegap进行php登录
- 从手机中选择多个图像'使用phonegap的多媒体资料
- cordova-2.0.0.js不适用于使用phonegap的android
- Phonegap 3.7.0手电筒插件没有'不起作用
- PhoneGap选项卡栏自定义字体,背景图案
- Xpath运行缓慢的查询
- LocalStorage phonegap摄像头图像
- 在phonegap中为android调用onload函数的最佳方式
- 在PhoneGap应用程序中检测缓慢的互联网连接
- IPhone应用程序缓慢使用phonegap
- PhoneGap游戏,canvas和缓慢的javascript
- 为什么PhoneGap地理定位API导致我的页面加载如此缓慢