zoukankan      html  css  js  c++  java
  • IOS--方法积累

    1.

    计算两个日期之间相差几天几小时几分钟

      NSDateFormatter *dateFormatter=[[NSDateFormatter alloc] init];

       [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
       NSDate *  senddate=[NSDate date];
       //结束时间
       NSDate *endDate = [dateFormatter dateFromString:@"2014-6-24 00:00:00"];
       //当前时间
       NSDate *senderDate = [dateFormatter dateFromString:[dateFormatter stringFromDate:senddate]];
       //得到相差秒数
       NSTimeInterval time=[endDate timeIntervalSinceDate:senderDate];
        
       int days = ((int)time)/(3600*24);
       int hours = ((int)time)%(3600*24)/3600;
       int minute = ((int)time)%(3600*24)600/60;
       
       if (days <= 0&&hours; <= 0&&minute; <= 0)
           dateContent=@"0天0小时0分钟";
       else
           dateContent=[[NSString alloc] initWithFormat:@"%i天%i小时%i分钟",days,hours,minute];
     
    2.动画执行完之后才执行某动作:

                    [CATransaction begin];

                    [CATransaction setCompletionBlock:^{

                        // animation has finished

                    }];

           // do some work eg:

                    [_myTableView beginUpdates];

                    [_insurancePeopleArray removeObjectAtIndex:deleteIndex-10-1];

                    NSIndexPath * indexPathOld = [NSIndexPath indexPathForRow:deleteIndex-10 inSection:0];

                    NSArray *array=[NSArray arrayWithObjects:indexPathOld, nil];

                    [self.myTableView deleteRowsAtIndexPaths:array withRowAnimation:UITableViewRowAnimationFade];

                    [_myTableView endUpdates];

                    [CATransaction commit];

  • 相关阅读:
    【简报】一款使用静态图片生成动画的jQuery插件:JZoopraxiscope
    使用jQuery timelinr和animate.css创建超酷的CSS动画时间轴特效
    超酷信息图分享:你属于哪类geek?
    数据库操作优化
    android R.java aapt
    xml sax 解析 & 符号
    sql server2000 完全卸载
    cmd 命令总结
    手动打包 解释
    bat 执行 java jar包
  • 原文地址:https://www.cnblogs.com/howdoudo/p/4069903.html
Copyright © 2011-2022 走看看