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

iOS项目开发经验:【常用代码4】

2012-10-18 01:52 585 查看
<4-1>获取当前时间

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 iphone date 电话