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