• iOS开发基础知识--碎片34


    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;
        }
    }
    复制代码
  • 相关阅读:
    MySQL存储引擎--MyISAM与InnoDB区别
    HTTP Keep-Alive模式
    php通过curl下载远程图片实例
    使用PHP QR Code生成二维码
    PHP中输出文件,怎么区别什么时候该用readfile() , fread(), file_get_contents(), fgets()
    SSDB 一个高性能的支持丰富数据结构的 NoSQL 数据库, 用于替代 Redis.
    html头文件设置常用之<meta>设置缓存
    redis使用watch完成秒杀抢购功能
    Linux信号(signal) 机制分析
    php信号处理
  • 原文地址:https://www.cnblogs.com/LiLihongqiang/p/5802186.html
Copyright © 2020-2023  润新知