iOS 遇到的小知识点总结

本文分享了iOS开发过程中的实用技巧,包括如何隐藏和显示NavigationController的navigationBar、页面跳转后的正确返回方法、设置按钮样式、UITableViewCell的选中颜色调整、UITableViewStyle的设置、在本页面控制下一个页面的back状态、UITableViewHeader或FooterView的使用注意事项、清除Xcode缓存的方法、iOS语言限制等关键知识点。

在开发过程中总是遇到一些小的知识点,太散不容易记住,每次还需要各种找,今天想把遇到的知识点总结起来,以备日后查看

1. 对NavigationController 中的navigationBar 进行隐藏以及显示会影响到其他的页面,因为 NavigationController 是全局共用一个的,所以我们在当前页面需要隐藏或者显示的时候不要忘了要在离开该页面时候恢复NavigationController 的状态

-(void)viewWillAppear:(BOOL)animated{
    self.navigationController.navigationBar.hidden = YES;
}
-(void)viewWillDisappear:(BOOL)animated{
     self.navigationController.navigationBar.hidden = NO;
}

2.我们在进行页面跳转之后还想回到原来的页面不要使用跳转到该页面时候使用的 Push 或者 Present 方法,要使用下面的“返回”方法

    [[self navigationController] popViewControllerAnimated:YES];

3.设置按钮的边框以及圆角

[doneBtn.layer setMasksToBounds:YES];
//    [doneBtn.layer setCornerRadius:8.0]; //设置矩圆角半径
    [doneBtn.layer setBorderWidth:1.0];   //边框宽度
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGColorRef colorref = CGColorCreate(colorSpace,(CGFloat[]){ 1, 0, 0, 1 });
    [doneBtn.layer setBorderColor:colorref];//边框颜色


4.UITableViewCell 选中不变色

    cell.selectionStyle = UITableViewCellSelectionStyleNone;

5.UITableViewStyleplain 类型无线

      myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;

6.在本页面控制下一个页面的back状态以及事件

self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:self action:@selector(click_backBarButtonItem:)];

- (void)click_backBarButtonItem:(UIBarButtonItem *)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

7.在使用UITableView 的HeaderView 或者FooterVIew 的时候必须设定 View 的高度

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 44.f;
}
- (UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    SearchTableView *headerView = [[SearchTableView alloc]init];
    return headerView;
}

8.清除Xcode 的缓存文件 

前往->文件夹->~/Library/Developer/Xcode/DerivedData    回车  删除即可

9.iOS语言是不支持多继承的,切记切记

未完待续。。。

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值