博文

图片旋转时的边缘抗锯齿的三种方法以及性能

首先,系统给出的layer中的抗锯齿方法,简单粗暴,一个开关就搞定了。 layer.allowsEdgeAntialiasing = true 第二种,在info.plist中加入键值: "Renders with edge antialiasing" YES 即可。 第三种,给图像加上1px的透明,UIImage的category方法如下所示: - (UIImage *)antiAlias { CGFloat border = 1.0f; CGRect rect = CGRectMake(border, border, self.size.width-2*border, self.size.height-2*border); UIImage *img = nil; UIGraphicsBeginImageContext(CGSizeMake(rect.size.width,rect.size.height)); [self drawInRect:CGRectMake(-1, -1, self.size.width, self.size.height)]; img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); UIGraphicsBeginImageContext(self.size); [img drawInRect:rect]; UIImage* antiImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return antiImage; } 前两种是系统给出的方法,简单粗暴,但是第三种比较另类但是如果屏幕上出现大批量图片的时候,该方法可以提供更好的性能。 在第三种方法中,不能只用UIGraphicsBeginImageContext(imageRect.size);否则图像会变模糊。 应该再使用UIGraphicsBeginImageContextWithOptions

iOS9里面的强制Https带来的一系列问题的解决方案(未完全覆盖所有情况)

图片
如果要用到http协议,那么需要在info.plist中添加如下条目: 如果用到了微信sdk,还需要增加如下条目: 如果其他sdk出现不正常现象 也许 也需要将url scheme加入其中。

自定义push和pop动画(iOS7+)

图片
UINavigationControllerDelegate新增了如下方法来返回动画控制对象 - ( id < UIViewControllerAnimatedTransitioning >)navigationController: animationControllerForOperation: fromViewController: toViewController: 要实现自定义的动画效果 只要在上述方法中返回一个实现了  <UIViewControllerAnimatedTransitioning>  协议的对象 - ( NSTimeInterval )transitionDuration:( id < UIViewControllerContextTransitioning >)transitionContext { // return animation duration here. } - ( void )animateTransition:( id < UIViewControllerContextTransitioning >)transitionContext { // implement animation here } 示例 实现协议  <UIViewControllerAnimatedTransitioning> - ( NSTimeInterval )transitionDuration:( id < UIViewControllerContextTransitioning >)transitionContext { return 0.25 } - ( void )animateTransition:( id < UIViewControllerContextTransitioning >)t...

Push时隐藏Tabbar

早就写了,不知咋地找不到了 = =b 用到了没在帖子里搜到又来发一帖~ 可以在要隐藏的ViewController里的init方法里加上: self .hidesBottomBarWhenPushed = YES ;   或者假设定义的ViewController是vc,那么应该加这一句: vc .hidesBottomBarWhenPushed = YES ;  或 [vc  setHidesBottomBarWhenPus hed : YES ];

通过邮件发博客-测试

测试一下,行的话以后就用Mac自带的邮件客户端来发博客了~

viewWillAppear不执行的解决办法

UITableViewController或UIViewController中使() 后viewWillAppear:(BOOL)animated不执行 解决方法如下: 先在 *.h 头文件里加上<UINavigationControllerDelegate> 接着在*.m 文件里加上相关代码 self.navigationController.delegate=self; 再使用此时navigationController的代理函数,就OK了。 -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [viewController viewWillAppear:animated]; } -(void)viewWillAppear:(BOOL)animated { NSLog(@"现在可以使用了"); } 代码实例: MyOrders.h @interface MyOrders : UIViewControllerlegate>{ } @property(nonatomic,retain)IBOutlet UITableView *table; MyOrders.m - (void)viewDidLoad { [super viewDidLoad]; self.navigationController.delegate=self; } -(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated { [viewController viewWillAppear:animated]; } -(void)viewWillAppear:(BOOL)a...

如何在Tableview中使用UITextField

我认为在Tableview中使用UITextField的最大难题就是如何找到Textfield以及在面对TableviewCell的重用机制时的数据同步问题。 以下摘自http://blog.sina.com.cn/s/blog_7d018cc601018ya5.html 首先需要解决的问题就是如果textfield比较靠下,那么键盘弹出会挡住这个cell。 解决方法: 由于TableView继承自UIScrollView使其滚动到上面即可,所以重写UITextFieldDelegate的方法 -(void)textFieldDidBeginEditing:(UITextField *)textField {     if(textField==userNameTextField) //或者根据tag if(textField.tag)     [_tableview setContentOffset:CGPointMake(0, 100) animated:YES]; } -(void)textFieldDidEndEditing:(UITextField *)textField {     [_tableview setContentOffset:CGPointMake(0, 0) animated:YES]; } 或者在初始化UITextField对象实例时添加事件 [checkCodeTextField addTarget:self action:@selector(upLayout) forControlEvents:UIControlEventEditingDidBegin]; [checkCodeTextField addTarget:self action:@selector(downLayout) forControlEvents:UIControlEventEditingDidEnd]; 关于文本框的输入 在一个文本框输入结束返回的时候,释放自身的响应级别resignFirstResponder,让下一个文本框成为焦点,即变成第一响应控件becomeFirstResponder,具体为:重写UITextFieldDelegate方法。下面的写法前提是在定义文本框时...