• ios7注意事项随笔


    1,修改状态栏的样式和隐藏。

    首先,需要在Info.plist配置文件中,增加键:UIViewControllerBasedStatusBarAppearance,并设置为YES;

    然后,在UIViewController子类中实现以下两个方法:

    - (UIStatusBarStyle)preferredStatusBarStyle
    {
        return UIStatusBarStyleLightContent;
    }
    
    - (BOOL)prefersStatusBarHidden
    {
        return NO;
    }
    最后,在需要刷新状态栏样式的时候,调用[self setNeedsStatusBarAppearanceUpdate]方法即可刷新
    
    注意:
    [self setNeedsStatusBarAppearanceUpdate]在push  或者 present 的controller里面调用才起作用。

    2,UITableViewCell的定制。

    以前可以直接继承UITableViewCell然后drawRect;

    现在不行了,现在的UITableViewCell包含了一个scrollView,你重绘了UITableViewCell将会被这个scrollView遮住而完全没法显示.

    解决思路:

    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

    {

    UITableViewCell * cell = [[[UITableViewCellallocinitWithStyle:UITableViewCellStyleDefaultreuseIdentifier:nilautorelease];

    UIView * subview = [[[XXView allocinitautorelease];

    subview.userInteractionEnabled = NO;// 不设为NO会屏蔽cell的点击事件

    subview.backgroundColor = [UIColorclearColor];// 设为透明从而使得cell.backgroundColor有效.

    subview.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

    [cell.contentView addSubview:subview];// cell.contentView是个readonly属性,所以别想着替换contentView了.

    return cell;

    }

    3,用户界面设计中,新增了一个重要的概念:UIKit动力

    默认支持如下5种动力行为:吸附行为(UIAttachmentBehavior),碰撞行为(UICollisionBehavior),重力行为(UIGravityBehavior),推动行为(UIPushBehavior),捕捉行为(UISnapBehavior;

    4,将TextKit整合到所有基于文本的控件中(Text Kit可以对程序中的文本内容进行精致的排版)。

    5,多任务

    iOS7中,应用程序的后台执行模型,新增了如下两种类型:

    1.fetch:

    应用程序可以从网络中有规律的下载新数据;

    注册方法为:在程序的Info.plist中,将UIBackgroundModes键值设置为fetch,然后在app delegate中,使用方法setMinimumBackgroundFetchInterval:来设置下载新数据操作之间的最小时间间隔。另外,必须在app delegate中实现application:performFetchWithCompletionHandler:方法以执行任意的下载。

    2.remote-notifaction:

    在iOS7中,通过推送通知,可以启动一个后台下载操作任务。

    要使用这种模型,只需要将程序Info.plist文件中的UIBackgroundModes键值设置为remote-notification,然后在app delegate中实现application:didReceiveRemoteNotification:fetchCompletionHandler: 方法。

    6,UIView类增加属性tintColor:可以使用一个tint color,并对view和它的subview有影响。

    7,UIViewController增加: View controller之间的切换(transition)可以自定义、驱动式交互(driven interactively),或者完全根据自己指定的切换方式来替换。

    8,UIView和UIScreen提供了一个新的方法:snapshot——返回一个view,可以用来显示程序的内容。 

    9,UIFontDescriptor对象使用一个属性字典来描述字体。通过font descriptor可以与其它平台相互交互。UIFont和UIFontDescriptor类支持动态调整字体大小。

    10,UIApplicationDelegate协议新增了处理后台获取数据的操作。

    - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler NS_AVAILABLE_IOS(7_0); 

    - (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult result))completionHandler NS_AVAILABLE_IOS(7_0); 

    - (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler NS_AVAILABLE_IOS(7_0);

    11,Table view支持对row或其他元素高度的评估(estimating),这样可以提升Table view的滚动性能。

    12, Media Player Framework

          在Media Player framework中,MPVolumeView类可以判断用户选择的无线路由(wireless route,例如AirPlay和Bluetooth)是否可用。你也可以判断无线路由当前是否可用。关于新接口信息,请参看framework的头文件。关于Media Player framework涉及到的类,请参看Media Player Framework Reference。

    13, AV Foundation Framework

     AVAudioSession支持一些新的行为:可以选择音频输入的首选项,包括来自内置麦克风的音频;支持多通道的输入和输出

    花开花谢春不管,水暖水寒鱼自知.
  • 相关阅读:
    【myEcplise2015】导入喜欢的主题
    【SVN】删除SVN上的历史资源路径和SVN上的历史用户信息
    【Linux】linux命令大全
    【Linux】在虚拟机上安装CentOS7
    Spring MVC+Mybatis 多数据源配置
    Spring 加载类路径外的资源文件
    OkHttp使用详解
    在虚拟机搭建JStrom
    在Windows下搭建RocketMQ
    解决confluence的乱码问题
  • 原文地址:https://www.cnblogs.com/taintain1984/p/3484512.html
Copyright © 2020-2023  润新知