大佬教程收集整理的这篇文章主要介绍了ios – 如何在UITableViewCell中获取UIButton的indexPath?,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我在-cellForRowATindexPath中的代码:
UIView *view=(UIView*)[cell.contentView viewWithTag:indexPath.row+444]; UIImageView *img=(UIImageView*)[cell.contentView viewWithTag:indexPath.row+999]; img.image=[UIImage imagenamed:@"BHCS_empty.png"]; if(Integer!=50) { NSInteger y_axis=0; NSArray *Arr=[tableSubCategoryArr objectATindex:indexPath.row]; img.image=[UIImage imagenamed:@"BHCS_SELEcted.png"]; view.Frame= CGRectMake(0,50,281,Integer-50); for (int i=0; i<[Arr count]; i++) { NSLog(@"arr %@",[Arr objectATindex:i]); UIButton *Btn=[UIButton buttonWithType: UIButtonTypeCustom]; Btn.frame=CGRectMake(0,y_axis,44); [Btn setImage:[UIImage imagenamed:@"BHCS_panel.png"] forState:UIControlStateNormal]; [Btn addTarget:self action:@SELEctor(subCategoryBtnClicked:) forControlEvents:UIControlEventTouchUpInside]; [Btn setTag:i+100]; [view addSubview:Btn]; UILabel *nameLbl=[[UILabel alloc]initWithFrame:CGRectMake(20,248,44)]; nameLbl.text = [[Arr objectATindex:i]objectForKey:@"SubCategoryName"]; nameLbl.textColor = [UIColor whiteColor]; nameLbl.BACkgroundColor=[UIColor clearColor]; panelTableView.separatorColor = [UIColor colorWithPatternImage:[UIImage imagenamed:@"BHCS_panel_div1.png"]]; nameLbl.font = [UIFont fontWithName:@"Helvetica" size:12.0f]; [view addSubview:nameLbl]; y_axis=y_axis+44+1.3f; } }
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tableView]; NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonPosition];
以上是大佬教程为你收集整理的ios – 如何在UITableViewCell中获取UIButton的indexPath?全部内容,希望文章能够帮你解决ios – 如何在UITableViewCell中获取UIButton的indexPath?所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。