IOS开发基础知识--碎片34

1:第三方插件SKSTableView在IOS7.1.1出现闪退的问题

解决办法,修改其内部源代码:

(NSInteger)subRow
{
id indexpath = [NSIndexPath class];
id subRowObj = objc_getAssociatedObject(indexpath, SubRowObjectKey);
return [subRowObj integerValue];
}

(void)setSubRow:(NSInteger)subRow
{
id subRowObj = [NSNumber numberWithInteger:subRow];
id indexpath = [NSIndexPath class];
objc_setAssociatedObject(indexpath, SubRowObjectKey, subRowObj, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}

 2:UITableViewCell属性highLighted、selected的区别

自定义一个cell继承自UITableViewCell,然后重载它的以下两个方法:

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated;

- (void)setSelected:(BOOL)selected animated:(BOOL)animated;

这两个方法一个是设置cell的高亮状态,另一个是设置cell的选中状态。当我们点击cell的时候,其实是先设置cell的高亮状态为YES,然后松手的时候再将cell的高亮状态设置为NO,接着才是设置cell的选中状态为YES,最后才会去调用delegate中的tableview:didSelectRowAtIndexPath:方法。

由此可见:cell的高亮状态是不能持久的,即tap的时候会变成高亮,松手的时候就会自动设置为非高亮状态。而cell的选中状态则是可以持久的,我们不去触发它改变状态,则选中状态就不会

下面实例为结合POP做的动画效果(当选中时跟松开都有一个相应的动画效果):

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}

- (void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated
{
    [super setHighlighted:highlighted animated:animated];
    if (self.highlighted) {
        POPBasicAnimation *scaleAnimation = [POPBasicAnimation animationWithPropertyNamed:kPOPViewScaleXY];
        scaleAnimation.duration = 0.1;
        scaleAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(1, 1)];
        [self.textLabel pop_addAnimation:scaleAnimation forKey:@"scalingUp"];
    } else {
        POPSpringAnimation *sprintAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPViewScaleXY];
        sprintAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(0.9, 0.9)];
        sprintAnimation.velocity = [NSValue valueWithCGPoint:CGPointMake(2, 2)];
        sprintAnimation.springBounciness = 20.f;
        [self.textLabel pop_addAnimation:sprintAnimation forKey:@"springAnimation"];
    }
}

 3: UIWebView在IOS9下底部出现黑边解决方式

UIWebView底部的黑条很难看(在IOS8下不会,在IOS9会出现),特别是在底部还有透明控件的时候,隐藏的做法其实很简单,只需要将opaque设为NO,背景色设为clearColor即可

4:UIViewControl中setEdgesForExtendedLayout运用

在iOS 7中,苹果引入了一个新的属性,叫做[UIViewController setEdgesForExtendedLayout:],它的默认值为UIRectEdgeAll。当你的容器是navigation controller时,默认的布局将从navigation bar的顶部开始。这就是为什么所有的UI元素都往上漂移了44pt。

- (void)viewDidLoad
{
    [super viewDidLoad];

    //让屏幕从导航栏下开始算(0,0)
    if ([self respondsToSelector:@selector(setEdgesForExtendedLayout:)]) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }
}

 

posted @ 2016-02-19 12:18  踏浪帅  阅读(609)  评论(0编辑  收藏  举报