3二、UIImage+Scale缩放图片ide
UIImage能够加载图片,可是咱们想要获得一张缩小或放大的图片,利用UIImage不能作到,下面咱们添加一个UIImage的分类,用来实现UIImage中图片的放大和缩小。函数
首先,建立一个UIImage+Scale类。字体
而后,实现该类的方法:spa
#import <UIKit/UIKit.h>.net
@interface UIImage (scale)code
-(UIImage*)scaleToSize:(CGSize)size;orm
@end 对象
#import "UIImage+Scale.h"接口
@implementation UIImage (scale)图片
-(UIImage*)scaleToSize:(CGSize)size
{
// 建立一个bitmap的context
// 并把它设置成为当前正在使用的context
UIGraphicsBeginImageContext(size);
// 绘制改变大小的图片
[self drawInRect:CGRectMake(0, 0, size.width,size.height)];
// 从当前context中建立一个改变大小后的图片
UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
// 使当前的context出堆栈
UIGraphicsEndImageContext();
// 返回新的改变大小后的图片
return scaledImage;
}
最后,就是该类的使用了:
#import "UIImage+Scale.h"
[[UIImage imageNamed:”p.png”] scaleToSize:CGSizeMake(252.0f,192.0f)];
3三、Coreplot:在散点图中,legendTitleForBarPlot不会被调用
legendTitleForBarPlot是柱状图的数据源方法,在散点图的数据源委托CPTScatterPlotDataSource 中没有该方法。要定制 legend 的标题,惟一的方法是指定plot 的 title 属性。若是 title 为空,则使用 identifier 属性。
3四、 setHidesBackButton不能隐藏返回按钮
将setHidesBackButton:animated:移到 viewDidAppear: 方法,而不要在 viewWillAppear:或者viewDidLoad方法中。
3五、cannotfind protocol declaration NSURLConnectionDelegate
iOS5开始NSURLConnectionDelegate被deprecated,在NSURLConnection.h中,这些方法变成了非正式协议。同时复制了一份这些方法的拷贝到正式协议NSURLConnectionDataDelegate中。你能够直接将类接口声明的<NSURLConnectionDelegate>删除,并实现这些方法,从而使用非正式协议。
3六、警告“Property'ssynthesized getter follows Cocoa naming convention for returning 'owned'objects”
要synthesized的属性中,属性名不得以“new”开头,好比“newFeature”。
3七、 Implicit declaration of function 'xxx' is invalidin C99
这是Xcode的一个bug。当编译器第一次看见函数定义,却未找到该函数原型时会报此错误。解决方法是在函数定义以前加入函数原型声明。注意,把函数原型声明语句插入到类的interface声明内(.h头文件),或者的类implementation语句以前(.m文件)。
3八、-[UIImageresizableImageWithCapInsets:]: unrecognized selector
这个方法是iOS5中新增的,在iOS4中请使用stretchableImageWithLeftCapWidth:topCapHeight:方法。代码:
if([img respondsToSelector:@selector(resizableImageWithCapInsets:)])
{//for iOS 5+
img=[srcImg resizableImageWithCapInsets:UIEdgeInsetsMake(0, 6, 0, 6)];
}else{//iOS 4 compatibility
img=[srcImg stretchableImageWithLeftCapWidth:6 topCapHeight:0];
}
3九、计算指定字体的字符串Size
CGSizemaximumLabelSize = CGSizeMake(250 ,MAXFLOAT);
CGSizeexpectedLabelSize = [LABEL.text sizeWithFont:[UIFontsystemFontOfSize:UILabel.font]
constrainedToSize:maximumLabelSize
lineBreakMode:UILineBreakModeWordWrap];
expectedLabelSize即根据字体、最大size限制、换行模式计算出来的实际Size。
40、ASIHTTPRequestclearDelegateAndCancel方法致使程序崩溃
ASIHTTPRequest并不会持有delegate对象,当你取消一个request或delegate释放后,为了不调用释放了的delegate方法,咱们应当取消request。可是clearDelegateAndCancel方法会致使一个调用deallocated对象错误并崩溃。
为了不这个,你应当(针对1.8.1及以前的版本):
在delegate中持有ASIHTTPRequest对象;
当释放delegate或取消request时,使用不要调用clearDelegateAndCancel而改用“[requestrelease],request=nil;”。
4一、 Castof 'int' to 'CAMediaTimingFunction *' is disallowed with ARC
如下代码致使上述错误:
transition.timingFunction= UIViewAnimationCurveEaseInOut;
事实上,就算在MRC(手动内存管理)中,这句代码也是不正确的。之因此可以不出错,是由于UIViewAnimationCurveEaseInOut一般为0,转换过来就变成了nil。实际上这句代码应该修改成:
[animationsetTimingFunction:[CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut]];