Как я фиксирую ошибку NSURLErrorDomain-999 в iPhone 3.0 OS

Я также видел, что это также сделано (который я использую в UIButtons для нормального и выделенного состояния, поскольку кнопки не подходят resize). Благодарность идет тому, кем был первоначальный автор.

Сначала создайте пустой файл .h и .m с именами UIImageResizing.h и UIImageResizing.m

// Put this in UIImageResizing.h
@interface UIImage (Resize)
- (UIImage*)scaleToSize:(CGSize)size;
@end

// Put this in UIImageResizing.m
@implementation UIImage (Resize)

- (UIImage*)scaleToSize:(CGSize)size {
UIGraphicsBeginImageContext(size);

CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, 0.0, size.height);
CGContextScaleCTM(context, 1.0, -1.0);

CGContextDrawImage(context, CGRectMake(0.0f, 0.0f, size.width, size.height), self.CGImage);

UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

return scaledImage;
}

@end

Включите этот файл .h в любой файл .m, в котором вы собираетесь использовать функцию и затем назовите это так:

UIImage* image = [UIImage imageNamed:@"largeImage.png"];
UIImage* smallImage = [image scaleToSize:CGSizeMake(100.0f,100.0f)];
51
задан dlamblin 22 June 2009 в 07:25
поделиться

1 ответ

I was able to find the answer here.

This thread contained this description for this error: This error may occur if an another request is made before the previous request of WebView is completed...

I worked around this by ignoring this error and letting the webview continue to load.

if ([error code] != NSURLErrorCancelled) {
//show error alert, etc.
}
119
ответ дан 7 November 2019 в 09:46
поделиться
Другие вопросы по тегам:

Похожие вопросы: