IOS开发过程中的学习的知识(1)
2015-01-07 10:35
441 查看
IOS新手,在开发中遇到的一些细节问题,总结一下,以免后来用到。
总结一下控件。
一、UITableview
1、分割线左边短一块
系统自带的控件的分隔符是左边短一块的,详见短信的界面。为了使其与屏幕一边长,需要加入如下代码
(1)如果该界面是UITabViewController,则需加入
- (void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
}
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
(2)如果只是UITableView控件,先在viewDidLoad中加入
if ([_table respondsToSelector:@selector(setSeparatorInset:)]) {
[_table setSeparatorInset:UIEdgeInsetsZero];
}
if ([_table respondsToSelector:@selector(setLayoutMargins:)]) {
[_table setLayoutMargins:UIEdgeInsetsZero];
}
然后
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
2、去掉多余的项
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor clearColor];
[_table setTableFooterView:view];
[_table setTableHeaderView:view];
3、下拉刷新
[_table addSubview:UIRefreshControl];//针对单独的UITableView控件,UITableViewController有一个RefreshControl的私有成员。
二、UILabel
1、自动换行的Label
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
_attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15.0], NSParagraphStyleAttributeName:paragraphStyle};
CGSize sizedate = [_label.text boundingRectWithSize:CGSizeMake(self.view.frame.size.width-16, 999) options:NSStringDrawingUsesLineFragmentOrigin attributes:_attributes context:nil].size;
CGRect rectdate =_label.frame;
rectdate.size.height = sizedate.height;
_label.frame = rectdate;
然后再将这个Size赋给Label;
三、UINavigationController
1、可以通过viewControllers访问其所有View,根节点为0;
四、控件布局
1、可以用setFrame来做,Frame是相对于父控件的坐标参数,而bounds是相对于界面的。
总结一下控件。
一、UITableview
1、分割线左边短一块
系统自带的控件的分隔符是左边短一块的,详见短信的界面。为了使其与屏幕一边长,需要加入如下代码
(1)如果该界面是UITabViewController,则需加入
- (void)viewDidLayoutSubviews
{
if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {
[self.tableView setSeparatorInset:UIEdgeInsetsMake(0,0,0,0)];
}
if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {
[self.tableView setLayoutMargins:UIEdgeInsetsMake(0,0,0,0)];
}
}
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
(2)如果只是UITableView控件,先在viewDidLoad中加入
if ([_table respondsToSelector:@selector(setSeparatorInset:)]) {
[_table setSeparatorInset:UIEdgeInsetsZero];
}
if ([_table respondsToSelector:@selector(setLayoutMargins:)]) {
[_table setLayoutMargins:UIEdgeInsetsZero];
}
然后
-(void) tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
[cell setSeparatorInset:UIEdgeInsetsZero];
}
if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
[cell setLayoutMargins:UIEdgeInsetsZero];
}
}
2、去掉多余的项
UIView *view = [[UIView alloc] init];
view.backgroundColor = [UIColor clearColor];
[_table setTableFooterView:view];
[_table setTableHeaderView:view];
3、下拉刷新
[_table addSubview:UIRefreshControl];//针对单独的UITableView控件,UITableViewController有一个RefreshControl的私有成员。
二、UILabel
1、自动换行的Label
NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];
paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;
_attributes = @{NSFontAttributeName:[UIFont systemFontOfSize:15.0], NSParagraphStyleAttributeName:paragraphStyle};
CGSize sizedate = [_label.text boundingRectWithSize:CGSizeMake(self.view.frame.size.width-16, 999) options:NSStringDrawingUsesLineFragmentOrigin attributes:_attributes context:nil].size;
CGRect rectdate =_label.frame;
rectdate.size.height = sizedate.height;
_label.frame = rectdate;
然后再将这个Size赋给Label;
三、UINavigationController
1、可以通过viewControllers访问其所有View,根节点为0;
四、控件布局
1、可以用setFrame来做,Frame是相对于父控件的坐标参数,而bounds是相对于界面的。
相关文章推荐
- iOS开发学习笔记(一) - 预备知识(1)
- ios开发学习过程中遇到的一些问题
- IOS开发学习笔记009-OC基本知识
- 如何学习才能快速成为ios开发高手--ios知识架构全方位探讨
- IOS科研IOS开发笔记学习基础知识
- IOS实际开发中学习到的知识
- IOS 开发学习二 C语言知识 字符串处理
- 【Objective-C】01-学习iOS开发前期知识积累之C语言知识大总结
- 【iOS知识学习】_iPhone开发必经
- iOS开发过程当中使用@synchronized关键字学习文档(一)
- 从今天开始学习iOS开发(iOS 7版)--构建一款App之App开发过程
- iOS开发学习手动内存管理暂时抛弃ARC以及retain/assign知识——iOS工程师面试必考内容
- IOS研究之IOS开发笔记基础知识学习
- iOS开发学习之iOS程序启动过程
- ios开发学习 --基础知识--系列教程
- IOS 核心开发课程---学习步骤---应该掌握的知识
- 【iOS开发-33】学习手动内存管理暂时抛弃ARC以及retain/assign知识——iOS工程师面试必考内容
- iOS 开发过程中记录的一些小知识(持续更新...)
- IOS开发学习记录----计算机相关知识
- iOS开发学习概述及知识整理