- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
该应用程序可以在iphone模拟器上正常运行,但是当我们在实际的iphone设备上运行它时,它在以下行崩溃:
[ucdView.image drawInRect:rect];
- (void)viewDidLoad{
[super viewDidLoad];
CLController = [[CoreLocationController alloc] init];
CLController.delegate = self;
[CLController.locMgr startUpdatingLocation];
currentLoc = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"redPin.png"]];
UIImage *ucdImage = [UIImage imageNamed:@"ucd.png"];
self.ucdView = [[UIImageView alloc] initWithImage:ucdImage];//creating a view for UCD image
ucdView.userInteractionEnabled = YES;
[self loadingFile];
UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
[myScrollView setMinimumZoomScale:0.35];
[myScrollView setMaximumZoomScale:2.0];
myScrollView.clipsToBounds = YES;
myScrollView.bounces = YES;
myScrollView.contentOffset = CGPointMake(1400, 700);
[myScrollView setContentSize:CGSizeMake(ucdImage.size.width, ucdImage.size.height)];
[myScrollView setDelegate:self];
[myScrollView addSubview:ucdView];//adding ucd view to scroll view
[self.view addSubview:myScrollView]; // adding scrollview to self.view main view
[myScrollView release];
//Drawing The Line
UIGraphicsBeginImageContext(ucdView.frame.size);
CGRect rect = CGRectMake(0, 0, ucdView.frame.size.width, ucdView.frame.size.height);
[ucdView.image drawInRect:rect];
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 3.0);
CGContextSetStrokeColorWithColor(context, [UIColor blueColor].CGColor);
CGFloat dashArray[] = {2,0,2,2};
CGContextSetLineDash(context, 3, dashArray, 5);
CGContextMoveToPoint(context,[self longt_to_x:[[path_array objectAtIndex:0] doubleValue]],[self lat_to_y:[[path_array objectAtIndex:1] doubleValue]]);
int path_length = [path_array count];
for(int i = 2; i<path_length; i = i+2){
CGContextAddLineToPoint(context,[self longt_to_x:[[path_array objectAtIndex:i] doubleValue]],[self lat_to_y:[[path_array objectAtIndex:i+1] doubleValue]]);
}
CGContextStrokePath(context);
ucdView.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
最佳答案
您没有说明崩溃的确切位置,但是您已经使用UIGraphicsBeginImageContext
创建了一个图像上下文,然后使用CGBitmapContextCreate
创建了另一个图像上下文。我的猜测是,下一个问题是问题(正确设置参数可能很棘手),而且无论如何都不是您想要的。因此将其更改为:
// Get the current drawing context which is the image context right now
CGContextRef context = UIGraphicsGetCurrentContext();
关于iphone - 在drawInRect:rect崩溃,我有解决方案,但不知道如何?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6775485/
我正在开发我的应用程序的新版本并尝试替换已弃用的消息,但我无法通过这个。 我不明白为什么 drawInRect:withAttributes 不工作。代码在 drawInRect:withFont:l
我正在将 iphone 应用程序移植到 Mac 应用程序,我必须将所有 UIKit 相关类更改为 AppKit。如果您能在这方面帮助我,我将不胜感激。这是执行以下部分的最佳方法吗.. Iphone 应
我想“提取” UIImage 的一部分,但我遇到了一些麻烦。 例如,原始图像大小为 320x480,我想在 CGRect(10, 10, 100, 100) 这样的矩形中渲染一个新的 UIImage
现在我有以下内容: - (void)drawRect { // some drawing [bgImage drawinRect:self.bounds]; // some d
我正在尝试使用渐变填充来填充一些文本,其中我将文本绘制模式设置为剪切,然后绘制渐变填充。问题是,每当我将文本绘制模式设置为剪辑时,文本字符串的每个字符都会放置在彼此的顶部,而不是按顺序绘制以形成单词
我正在做的是将 2 个图像合并为单个图像。 这是代码。 UIGraphicsBeginImageContext(CGSizeMake(1024, 768)); [image1 drawInRect:C
我对正确使用 UIImage 和方法 drawInRect 有疑问。 我使用 iPad 4,Xcode 版本 6.1.1 , IOS 8.1.2我使用了 ARC,我尝试过不使用 ARC 所以,我有图像
我有以下代码在 UITableViewCell 中绘制文本,它可以很好地绘制和返回文本,但在 UITableViewCell 的中心。所以我给它正确对齐但没有工作!! UIColor * textCo
我正在更新一个旧应用程序,但我无法使 drawInRect 在 PDF 上下文中工作。 我将已弃用的函数 CGContextShowTextAtPoint 替换为 CGContextShowTextA
我正在尝试在上下文中绘制文本,它起作用了。 我正在尝试为该文本设置一个 UIfont,但它不起作用。文字大小保持不变。 这是我的代码 - (UIImage *)imageByDrawingCircle
我有一个应用程序[基于窗口],我需要在屏幕上“绘制”一些图像,[我正在遵循一个实现一些自定义图表绘图的示例项目,这样做,但它不使用 UIImage View ,只是UI图像) 我正在使用 - (voi
我创建了一个名为 MySegment 的新类,它继承自 UIControl。 首先,我使用 CAGradientLayer 初始化了一条渐变线。 第二,[self.layer addSublayer:
我创建了一个自定义的 UIView 类,以便可以显示 Map 对象的内容。经过大量研究,我仍然无法确定为什么下面的方法不绘制任何东西: - (void)drawRect:(CGRect)rect {
正在尝试修复 iOS 应用程序中的一些警告并更改了此更新: [[self text] drawInRect:rect withFont:[UIFont systemFontOfSize:kFontSi
我在背景中画了一些图像。有时我的应用程序会因奇怪的错误而崩溃: function signature specialization of MyApp. 我检查了所有崩溃,并且所有崩溃都发生在不使用上
我正在使用 drawInRect: 将文本绘制到 UIView。我从服务器端脚本获取要绘制的文本。至少在一种情况下,字符\U00a0 出现在我从服务器接收到的字符串中,并且该单个字符破坏了 drawI
我正在尝试缩小 2 倍图像,然后在矩形中绘制 UIImage,但不知何故这没有任何效果。即使 .scale 属性发生变化,图像看起来仍具有相同的比例。 这是我的drawRect()的实现 ove
以高帧率将图像渲染和缩放到表面的最快方法是什么? 我正在使用 drawRect 以大约 30FPS 的速度绘制(缩放)NSBitmapImageRep,但它使用了大量的 CPU。 将 NSBitmap
我正在学习 OpenGLES,我正在尝试将 GLKViewer 放入 UIViewController 中。 我知道我可以通过使用 GLViewController 来解决主要问题,但我正在努力学习如
我在这个网站上读过一些关于使用drawInRect而不是CGContext绘制方法的帖子。它仍然把它画得颠倒吗?我认为使用 drawInRect 会将其正面朝上打印,坐标系起始于左上角? -(void
我是一名优秀的程序员,十分优秀!