ios7注意事项随笔

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

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

而后,在UIViewController子类中实现如下两个方法:less

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

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

2,UITableViewCell的定制。ide

之前能够直接继承UITableViewCell而后drawRect;性能

如今不行了,如今的UITableViewCell包含了一个scrollView,你重绘了UITableViewCell将会被这个scrollView遮住而彻底无法显示.字体

解决思路:fetch

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

{设计

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

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支持一些新的行为:能够选择音频输入的首选项,包括来自内置麦克风的音频;支持多通道的输入和输出

相关文章
相关标签/搜索