您的位置:首页 > 移动开发 > IOS开发

ios7 tweak

2013-10-21 18:14 465 查看
1.[UIView performWithoutAnimation:] 替代

[UIView setAnimationsEnabled:NO];

code here...

[UIView setAnimationsEnabled:YES];

2.实现tableView:estimatedHeightForRowAtIndexPath:代理函数或者设置estimatedRowHeight属性值,提供一个预估高度值,

对于可变高度的cell的表格视图可改进性能

3.UISearchDisplayController新增属性:displaysSearchBarInNavigationBar,可让搜索控件显示在导航栏,但不可与showsScopeBar同时设置为YES,即显示在导航栏的搜索控件不能有范围选择栏

4.UIResponder新增属性keyCommands,相应的有个新增类
UIKeyCommand,可用于捕获蓝牙键盘的按键事件,例:



- (NSArray *)keyCommands
{
return @[[UIKeyCommand keyCommandWithInput:@"f"
modifierFlags:UIKeyModifierCommand
action:@selector(searchKeyPressed:)]];
}

- (void)searchKeyPressed:(UIKeyCommand *)keyCommand
{
// Respond to the event
}


5.新增UIInputView,可用来自定义键盘或者扩展默认键盘

6.CTTelephonyNetworkInfo:用来判断手机当前的网络类型,是edge还是LTE或其他,currentRadioAccessTechnology的值可为:

CTRadioAccessTechnologyCDMA1x

CTRadioAccessTechnologyCDMAEVDORev0

CTRadioAccessTechnologyCDMAEVDORevA

CTRadioAccessTechnologyCDMAEVDORevB

CTRadioAccessTechnologyEdge

CTRadioAccessTechnologyGPRS

CTRadioAccessTechnologyHSDPA

CTRadioAccessTechnologyHSUPA

CTRadioAccessTechnologyLTE

CTRadioAccessTechnologyWCDMA

CTRadioAccessTechnologyeHRPD

CTTelephonyNetworkInfo *telephonyInfo = [CTTelephonyNetworkInfo new];
NSLog(@"Current Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
[NSNotificationCenter.defaultCenter addObserverForName:CTRadioAccessTechnologyDidChangeNotification
object:nil
queue:nil
usingBlock:^(NSNotification *note)
{
NSLog(@"New Radio Access Technology: %@", telephonyInfo.currentRadioAccessTechnology);
}];


7.下载字体:CTFontDescriptorMatchFontDescriptorsWithProgressHandler
获取可下载字体:

CFDictionary *descriptorOptions = @{(id)kCTFontDownloadableAttribute : @YES};
CTFontDescriptorRef descriptor = CTFontDescriptorCreateWithAttributes((CFDictionaryRef)descriptorOptions);
CFArrayRef fontDescriptors = CTFontDescriptorCreateMatchingFontDescriptors(descriptor, NULL);



Tint images with UIImage.renderingMode


UIImage *img = [UIImage imageNamed:@"myimage"];
img = [img imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];





新增UIApplicationUserDidTakeScreenshotNotification通知,当用户截屏时触发


UIScreenEdgePanGestureRecognizer

UIScreenEdgePanGestureRecognizer *recognizer = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(handleScreenEdgeRecognizer:)];
recognizer.edges = UIRectEdgeLeft;
[self.view addGestureRecognizer:recognizer];


keyboardDismissMode:scrollView滚动时隐藏[b]键盘[/b]

self.scrollView.keyboardDismissMode =
UIScrollViewKeyboardDismissModeOnDrag;//刚拖动scrollView就隐藏键盘

self.scrollView.keyboardDismissMode =
UIScrollViewKeyboardDismissModeInteractive;//从键盘上面点(scrollView未遮挡部分)向下滑动,键盘会跟着滑动;又往上滑动键盘也会跟着向上滑动

UIScrollViewKeyboardDismissModeNone//默认值,没有任何影响

参考网址:http://www.objc.io/issue-5/iOS7-hidden-gems-and-workarounds.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: