Learning(一)

1、如果iOS的系统是11.0,tableview下移64的解决办法

if (@available(iOS 11.0, *)) {

         self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

  }else {

   self.automaticallyAdjustsScrollViewInsets = NO;

self.tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);

2、cell上按钮传值

 当我们在一个自定义的tableView Cell上添加一个UIButton按钮时,点击按钮使用如下方法获取对应的indexPath。

 #pragma mark - 填写按钮动作/向下一个页面传值

 - (void)PracticeClick:(UIButton *)button{    

PractController *practice=[[PractController alloc]init];   

//1. 将button强转成你自定义cell类( FollowCell是自定义cell)   

FollowCell *cell = (FollowCell *)[button superview];   

 //2.使用tableView indexPathForCell来获取对应的indexPath   

NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];  

//3.获取cell对应的indexPath就可以实现传值了   

 practice.model = self.dataSource[indexPath.row];   

 FollowModel * teamDescModel = [self.NofollowArr objectAtIndex:indexPath.row];   

 if ([teamDescModel.followupStatus isEqualToString:@"0"]) {       

    practice.task = teamDescModel.taskId;      

    practice.customer = teamDescModel.customerId;   

  }   

 [self.navigationController pushViewController:practice animated:YES];    

3、设置label/Title按钮圆角(左上和右上)

 [self.Title.superview layoutIfNeeded]; 

UIRectCorner rectCorner = UIRectCornerTopLeft | UIRectCornerTopRight ;

 UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:self.Title.bounds byRoundingCorners:rectCorner cornerRadii:CGSizeMake(10, 10)]; 

 CAShapeLayer *shapeLayer = [CAShapeLayer layer];

shapeLayer.path = path.CGPath;

 self.Title.layer.mask = shapeLayer;

4、跳转到指定界面

PlusOneVC是要跳转的界面

PlusOneVC *plusVC = [[PlusOneVC alloc] init];

for (UIViewController *temp in self.navigationController.viewControllers) {

    if ([temp isKindOfClass:[PlusOneVC class]]) {

        [self.navigationController popToViewController:plusVC animated:YES];         

      }      

}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容