2017-03-03 10 views
0

は、私は複数のセクションでは、私はindexPathを取得する方法、その後がある場合、私は0 を設定InSectionので、私だけのセクション0 indexPathを与える特定のセクションindexPathが、このコードをしたいですか?複数のセクションを持つ行とセクションのインデックスを取得しますか?

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0]; 

私にそれを手伝ってください。

答えて

0

以下のコードは、作業

-(IBAction)btnClicked:(id)sender 
{ 
    CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:tableviewName]; 

    NSIndexPath *indexPath = [self.accountTablView indexPathForRowAtPoint:buttonPosition]; 

    NSLog(@"section index-----%ld",(long)indexPath.section); 
} 
+0

おかげman..Its便利です。.. –

0

tag属性のsenderがデフォルト値を返しています。
あなたがsenderの作成中に適切にtagを設定することを確認し、のように設定する必要があります。

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0]; 

をジャスト:やっている間今、senderが正しいindexPath値を返します

myView.tag = indexPath 

正確なインデックスを取得するためにタグが正しく設定されていることを確認してください(私はcellForRowAtIndexpathで推測しています)。あなたがボタンをクリックすると

関連する問題