iOS项目开发经验:【常用代码4】
2012-10-18 01:52
585 查看
<4-1>获取当前时间
<4-2>在子viewController中隐藏tabbar
<4-3>查看设备支持的字体:
for (NSString *family in [UIFont familyNames]) {
NSLog(@"%@", family);
for (NSString *fontName in [UIFont fontNamesForFamilyName:family]) {
NSLog(@"\t %@", fontName);
}
}
<4-4>开发调试和发布阶段日志控制,打开宏定义
#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
<4-5>去掉UITableView中Cell之间的分割线
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
<4-6>UITableView滚动到最下面
- (void)scrollToFoot:(BOOL)animated {
NSInteger section = [self.tableView numberOfSections];
if (section<1) return;
NSInteger row = [self.tableView numberOfRowsInSection:section-1];
if (row<1) return;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row-1 inSection:section-1];
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionBottom
animated:animated];
}
<4-7> UITextView支持超链接,电话
在iPhone 3.0后就支持UIDataDetectorTypes来检测数字和链接。
UIDataDetectorTypePhoneNumber
UIDataDetectorTypeLink
UIDataDetectorTypeNone
UIDataDetectorTypeAll
通过设置dataDetectorTypes属性就可以实现功能
- (void)viewDidLoad {
self.textView.dataDetectorTypes = UIDataDetectorTypeAll;
}
NSString *nowDateString = [NSDateFormatter localizedStringFromDate:[NSDate date] dateStyle:NSDateFormatterMediumStyle timeStyle:NSDateFormatterNoStyle];
<4-2>在子viewController中隐藏tabbar
viewController.hidesBottomBarWhenPushed = YES; [self.navigationController pushViewController:viewController animated:YES];
<4-3>查看设备支持的字体:
for (NSString *family in [UIFont familyNames]) {
NSLog(@"%@", family);
for (NSString *fontName in [UIFont fontNamesForFamilyName:family]) {
NSLog(@"\t %@", fontName);
}
}
<4-4>开发调试和发布阶段日志控制,打开宏定义
#ifndef __OPTIMIZE__
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
<4-5>去掉UITableView中Cell之间的分割线
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
<4-6>UITableView滚动到最下面
- (void)scrollToFoot:(BOOL)animated {
NSInteger section = [self.tableView numberOfSections];
if (section<1) return;
NSInteger row = [self.tableView numberOfRowsInSection:section-1];
if (row<1) return;
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:row-1 inSection:section-1];
[self.tableView scrollToRowAtIndexPath:indexPath
atScrollPosition:UITableViewScrollPositionBottom
animated:animated];
}
<4-7> UITextView支持超链接,电话
在iPhone 3.0后就支持UIDataDetectorTypes来检测数字和链接。
UIDataDetectorTypePhoneNumber
UIDataDetectorTypeLink
UIDataDetectorTypeNone
UIDataDetectorTypeAll
通过设置dataDetectorTypes属性就可以实现功能
- (void)viewDidLoad {
self.textView.dataDetectorTypes = UIDataDetectorTypeAll;
}
相关文章推荐
- iOS项目开发经验:【常用代码5】
- iOS项目开发经验:【常用代码3】
- iOS项目开发经验:【常用代码7】
- iOS项目开发经验:【常用代码2】
- iOS项目开发经验:【常用代码6】
- iOS项目开发经验:【常用代码1】
- iOS:使用Github托管自己本地的项目代码方式一:(Xcode方式:开发工具Xcode配置Git,由Xcode-->Source Control-->Commit)
- IOS开发效率之为Xcode添加常用的代码片段
- 02-IOS项目开发代码规范标准
- iOS-项目的目录结构能看出你的开发经验
- iOS开发常用代码
- iOS开发常用代码片段整理
- iOS高仿城觅项目(开发思路和代码)
- iOS开发常用代码(实用)
- iOS开发总结之项目开发中使用UITableView几百行代码搞定级联表格
- iOS开发中常用的代码
- ios开发中17个常用的小代码
- iOS 学习日志 :开发中常用的注释方法以及代码块
- iOS开发常用代码片段整理