设为首页 加入收藏

TOP

IOS开发基础知识--碎片40(一)
2017-10-13 10:28:40 】 浏览:5537
Tags:IOS 开发 基础知识 碎片

1:Masonry快速查看报错小技巧

self.statusLabel = [UILabel new];
[self.contentView addSubview:self.statusLabel];
MASAttachKeys(self.statusLabel);

[self.statusLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(self.contentView).offset(15.0f);
make.left.equalTo(self.contentView).offset(10.f);
make.height.equalTo(10);
make.bottom.equalTo(self.contentView);
}];

注意:MASAttachKeys会显示出比较明了的错误信息;

 

2:iOS跳转到系统设置

注意:想要实现应用内跳转到系统设置界面功能,需要先在Targets-Info-URL Types-URL Schemes中添加prefs

跳转到WIFI设置
if ([[UIApplication sharedApplication] 
        canOpenURL:[NSURL URLWithString:@"prefs:root=WIFI"]])
{
        [[UIApplication sharedApplication] 
        openURL:[NSURL URLWithString:@"prefs:root=WIFI"]];
}

跳转到蓝牙
if ([[UIApplication sharedApplication] 
        canOpenURL:[NSURL URLWithString:@"prefs:root=Bluetooth"]])
{
        [[UIApplication sharedApplication] 
        openURL:[NSURL URLWithString:@"prefs:root=Bluetooth"]];
}

跳转到通用
if ([[UIApplication sharedApplication] 
        canOpenURL:[NSURL URLWithString:@"prefs:root=General"]])
{
        [[UIApplication sharedApplication] 
        openURL:[NSURL URLWithString:@"prefs:root=General"]];
}

跳转到关于本机
if ([[UIApplication sharedApplication] 
        canOpenURL:[NSURLURLWithString:
        @"prefs:root=General&path=About"]])
{
        [[UIApplication sharedApplication] 
        openURL:[NSURL URLWithString:@"prefs:
            root=General&path=About"]];
}


跳转到定位服务
if ([[UIApplication sharedApplication] 
        canOpenURL:[NSURL URLWithString:@"prefs:
        root=LOCATION_SERVICES"]])
{
        [[UIApplication sharedApplication] 
        openURL:[NSURL URLWithString:@"prefs:
        root=LOCATION_SERVICES"]];
}


跳转到通知
if ([[UIApplication sharedApplication] 
        canOpenURL:[NSURL URLWithString:@"prefs:
        root=NOTIFICATIONS_ID"]])
{
      [[UIApplication sharedApplication] 
      openURL:[NSURL URLWithString:@"prefs:
      root=NOTIFICATIONS_ID"]];
}

 3:UITableView section随着cell滚动 

实现UITableView 的下面这个方法,
#pragma mark - Scroll
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
    CGFloat sectionHeaderHeight = 40;
       //固定section 随着cell滚动而滚动
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
        
    } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
        
    }

}

 4:TableView如何刷新指定的cell 或section  

//一个section刷新    

NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];    

[tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];    



//一个cell刷新    

NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];    

[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];  

 5:TableView另一种实现隔行空白的效果

增加总体条数,然后再求余判断

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *CELL
首页 上一页 1 2 3 下一页 尾页 1/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇Swift 数组 下一篇iOS常识名词解释 2016/04/05

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目