IOS开发过程中的学习的知识(1)

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是相对于界面的。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值