zoukankan      html  css  js  c++  java
  • ios 写项目的时候遇到的问题及解决方案(1)

    1.解决headerView不随cell一起滚动的问题

    解决方案:myHeaderView为自己创建的view加在tableHeadView上,
    self.tableView.tableHeadView=myHeaderView;
    2.去掉tableView 多余的表格线
    解决方案:tableView.tableFooterView=[[UIView alloc]init];
    3.UIColor 的RGBA定义颜色 (colorWithRed)
    解决方案:做界面的时候常常会用到UIColor这个类,这是苹果的一个表示颜色的类。
    想要表示一种颜色,UIColor 有默认的颜色,WhiteColor,BlackColor.....
    也可以用RGB来初始化颜色,当然还有个Alpha透明度。
    我的代码是这样的。
     UIColor *color = [UIColor colorWithRed:9 green:122 blue:255 alpha:1];
    始终达不到预想效果(9,122,255)。。。。
    网上查了下,再看看此方法的介绍,RGB和alpha值的范围是0~1,所以9,122,255就都被当作255处理了。
    正确:UIColor *color = [UIColor colorWithRed:9.0/255.0 green:122.0/255.0 blue:50.0/255.0 alpha:1];
    4.Xcode在APPstore上更新6.4,总是弹出别人的账号导致不能更新
    解决方案:因为你的itunes的App里的软件有的是用别人帐号购买的或者授权的,你需要删除它们重新下载才能用自己的账号更新
    5.真机测试时遇到app install fail的问题
    解决方案:把手机里的APP删掉,再安装新的APP,因为前后APP的配置文件可能不同,导致不能真机测试
    6.MJRefresh,刷新应用
    下载导入MJRefresh库,导入头文件;
    添加几行代码就可以了

    self.tableView.header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{

            // 进入刷新状态后会自动调用这个block

            

             dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

                 

               [self.newsTV reloadData];

                 

             });

        }];

    self.tableView.footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{

            // 进入刷新状态后会自动调用这个block

            

            dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{

                     

                     [self.newsTV reloadData];

               

                 });

        }];

    7.设置APP不转屏,保持竖屏状态
    解决方案:
    1.修改Info.plist文件的Supported interface orientations 
    2.在APPdeledate中添加
    - (BOOL)shouldAutorotate{
      return NO;

     }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

    {

        return interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ;

    }

    8.强制旋转问题

     问题解决了, 还算完美. 方法基本道理还是一样, 强制调用系统的自动旋转机制.


    竖屏点击按钮 旋转到横屏
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];//这句话是防止手动先把设备置为横屏,导致下面的语句失效.
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];

    横屏点击按钮, 旋转到竖屏
    [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationLandscapeLeft] forKey:@"orientation"];//这句话是防止手动先把设备置为竖屏,导致下面的语句失效.
        [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger:UIDeviceOrientationPortrait] forKey:@"orientation"];

    同时还要必须支持自动旋转
    - (BOOL)shouldAutorotate
    {
        return YES;
    }

    然后就是
    - (NSUInteger)supportedInterfaceOrientations
    {
        if (IS_IPHONE && self.isHalfScreen) { //如果是iPhone,且为竖屏的时候, 只支持竖屏
            return UIInterfaceOrientationMaskPortrait;
        }
        return UIInterfaceOrientationMaskLandscape; //否者只支持横屏
    }

    这里基本就可以了.
     
    9."The identity used to sign the executable is no longer valid"错误解决方法
     
    解决方法,到development.apple.com网站重新下载provision profile文件双击安装到Xcode上再运行
     
    10.Objective-C - 获取毫秒时间戳:

    获取方法:

    UInt64 recordTime = [[NSDate date] timeIntervalSince1970]*1000;
    首先 [[NSDate date] timeIntervalSince1970] 是可以获取到后面的毫秒 微秒的 ,只是在保存的时候省略掉了, 如一个时间戳不省略的情况下为 1395399556.862046 ,省略掉后为一般所见 1395399556 。所以想取得毫秒时用获取到的时间戳 *1000 ,想取得微秒时 用取到的时间戳 * 1000 * 1000 。

    如果你想格式化输出 可以:

     NSDateFormatter * formatter = [[NSDateFormatter alloc ] init]; 
     [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss:SSS"];  
    NSString *date =  [formatter stringFromDate:[NSDate date]]; 
     NSString *timeLocal = [[NSString alloc] initWithFormat:@"%@", date]; 
    NSLog(@"%@", timeLocal);
    
    
    
    淡然;敬胜怠,义胜欲;知其雄,守其雌
  • 相关阅读:
    ASP.NET CORE 使用Consul实现服务治理与健康检查(2)——源码篇
    ASP.NET CORE 使用Consul实现服务治理与健康检查(1)——概念篇
    Asp.Net Core 单元测试正确姿势
    如何通过 Docker 部署 Logstash 同步 Mysql 数据库数据到 ElasticSearch
    Asp.Net Core2.2 源码阅读系列——控制台日志源码解析
    使用VS Code 开发.NET CORE 程序指南
    .NetCore下ES查询驱动 PlainElastic .Net 升级官方驱动 Elasticsearch .Net
    重新认识 async/await 语法糖
    EF添加
    EF修改部分字段
  • 原文地址:https://www.cnblogs.com/xblover/p/4806502.html
Copyright © 2011-2022 走看看