蓝懿ios技术交流和心得分享12.14

MBProgressHUB框架:主要用于网络请求显示加载进度,应用范围广泛。

1、基本显示效果:

  •  [MBProgressHUD showHUDAddedTo:self.viewanimated:YES];

       dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

           [NSThreadsleepForTimeInterval:3];

          dispatch_async(dispatch_get_main_queue(), ^{

              [MBProgressHUDhideHUDForView:self.view animated:YES];

           });

       });

2、显示进度:

  • MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.viewanimated:YES];

    hud.mode =MBProgressHUDModeAnnularDeterminate;

    hud.labelText =@"Loading";

    hud.color = [UIColorblueColor];

    hud.labelColor = [UIColorredColor];

   dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{

       for (int i=0; i<100; i++) {

           [NSThreadsleepForTimeInterval:.01];

          dispatch_async(dispatch_get_main_queue(), ^{

              hud.progress+=0.01;

              if (i==99) {

                 [hud hide:YES];

              }

           });

       }

    });

3、自定义效果:

  • MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.viewanimated:YES];

    hud.mode =MBProgressHUDModeCustomView;

    hud.labelText =@"Loading";

    hud.customView =[[UIImageView alloc]initWithImage:[UIImageimageNamed:@"8.jpg"]];

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT,0), ^{

               [NSThreadsleepForTimeInterval:3];

          dispatch_async(dispatch_get_main_queue(), ^{

                 [hud hide:YES];

           });

    });

 

  • 获取当前时间的秒数:拿到1970年到现在过的总秒数;

NSTimeInterval time = [[NSDate date] timeIntervalSince1970];

long long int date = (long long int)time;

NSLog(@”date\n%lld”, date); //1295322949

//把秒数转化成yyyy-MM-dd hh:mm:ss格式

NSDate *dd = [NSDate dateWithTimeIntervalSince1970:date];

NSLog(@”d:%@”,dd); //2011-01-18 03:55:49 +0000

//微博返回的时间格式​,字母为固定的,大小写不能错;

    NSDateFormatter *fmt = [[NSDateFormatteralloc] init];

//    EEE星期 MMM月 dd日 HH小时 mm分 ss秒 Z时区 yyyy年

    fmt.dateFormat = @"EEE MMM dd HH:mm:ss Z yyyy";

    //英文

  fmt.locale = [[NSLocalealloc] initWithLocaleIdentifier:@"en_US"];

       

//

 获得微博发布的具体时间 (倒推回去)

    NSDate *createDate = [fmt dateFromString:_created_at];

    //获取当前时间对象

    NSDate *nowDate = [NSDate date];

    long createTime = [createDate timeIntervalSince1970];

    long nowTime = [nowDate timeIntervalSince1970];

    long time = nowTime-createTime;

    if (time<<span se-mark="1">60) {

        return @"刚刚";

    }else if (time<<span se-mark="1">3600){

        return [NSString stringWithFormat:@"%ld分钟前",time/60];

    }else if (time<<span se-mark="1">3600*24){

        return [NSString stringWithFormat:@"%ld小时前",time/3600];

    }

//自己重新定义显示格式​

        fmt.

dateFormat

 = @"MM月dd日 HH:mm";

    return [fmt stringFromDate:createDate];

另外在分享一些常见 的错误:

1.[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key resultLabel.出错原因:sb控件和代码关联出错解决方案:找到相对应的页面的黄色圆点(ViewController)在此上面右键 删除 黄色叹号2.<__NSArrayM: 0x7c0320b0> was mutated while being enumerated.出错原因:forin循环时修改了数组 但继续循环了解决方案: 修改数组后 加break或return3.-[__NSArrayM objectAtIndex:]: index 3 beyond bounds [0 .. 0]'出错原因:数组角标越界解决方案:角标的取值 要小于数组的count4.-[ViewController addZombX]: unrecognized selector sent to instance 0x79174e00'出错原因:在ViewController中找不到方法

解决方案:在某个类中没有实现这个方法  或者是对象类型错了

5.This application is modifying the autolayout engine from a background thread出错原因:子线程中修改了界面解决方案:回到主线程修改就可以了6.An

instance 0x7fb6dad221e0 of class Mouse was deallocated

while key value observers were still registered with it

原因:监听了一个已经被释放的对象

解决方案:在适当的位置删除监听

    学习ios  重要还是要理清楚思路  在做或者看老师代码的时候 自己多想想为什么  不要自己看着就抄       另外还是要推荐一下 蓝懿IOS这个培训机构  和刘国斌老师刘国斌老师还是很有名气的,听朋友说刘老师成立了蓝懿iOS,,老师讲课方式很独特,能够尽量让每个人都能弄明白,有的比较难懂的地方,如果有的地方还是不懂得话,老师会换个其它方法再讲解,这对于我们这些学习iOS的同学是非常好的,多种方式的讲解会理解得更全面,这个必须得给个赞,嘻嘻,还有就是这里的学习环境很好,很安静,可以很安心的学习,安静的环境是学习的基础,小班讲课,每个班20几个学生,学习氛围非常好,每天都学到9点多才离开教室,练习的时间很充裕,而且如果在练习的过程中有什么困难,随时可以向老师求助,不像其它机构,通过视频教学,有的甚至学完之后都看不到讲师本人,问点问题都不方便,这就是蓝懿与其它机构的区别,相信在刘国斌老师的细心指导下,每个蓝懿学员都能找到满意的工作,加油!

                                                                  写博客第六十五天;

                                                                              QQ:565803433


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值