相关疑难解决方法(0)

如何从UICollectionViewCell访问UICollectionView中Cell的indexPath

我想动画UICollectionViewCell调用何时动作.
我已经做UICollectionViewCellInterface Builder,该UICollectionView还.现在我想indexPath在我的actionBtnAddToCard方法中得到正确的答案.

这就是我现在尝试的方式(ProduktViewCell.m中的方法):

- (IBAction)actionAddToCart:(id)sender {
    XLog(@"");

    // see this line
    NSIndexPath *indexPath = ??** how can i access the correct indexPath**??;
    SortimentViewController *svc = [[SortimentViewController alloc] initWithNibName:@"SortimentViewController_iPad" bundle:[NSBundle mainBundle]];
    [svc.collectionViewProdukte cellForItemAtIndexPath:indexPath];

    [svc collectionView:svc.collectionViewProdukte didSelectItemAtIndexPath:indexPath];
} 
Run Code Online (Sandbox Code Playgroud)

SortimentViewController是viewController,它继承了UICollectionView.
如何访问正确的indexPath?

更新1:编辑帖子以便更好地理解.

nsindexpath ibaction ios uicollectionview uicollectionviewcell

20
推荐指数
5
解决办法
6万
查看次数

如何在UITableViewCell中获取UIButton的indexPath?

我有一个UITableview多个细胞.在每个单元格上,我根据一些数组计数动态添加按钮.所以,当我点击一个按钮时,我就可以获得按钮的tag值.但是如何获得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, 281, 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, y_axis,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"]]; …
Run Code Online (Sandbox Code Playgroud)

xcode uitableview ios

11
推荐指数
4
解决办法
3万
查看次数