2016-03-28 1 views
-1

からNSIntegerコレクションビューからIOSのはNSIndexpath

- (void)buttonPressed:(id)sender 
{ 
    NSLog(@"button clicked"); 


    // CGPoint buttonPosition = [sender convertPoint:CGPointZero 
    //          toView: GlossaryCollView]; 
    NSIndexPath *centerCellIndexPath = 
    [self.GlossaryCollView indexPathForItemAtPoint: 
    [self.view convertPoint:[self.view center] toView:self.GlossaryCollView]]; 


    NSLog(@"cell index path :%@",centerCellIndexPath); 




} 

を選択したセルの位置を取得していこれは、値のNSLog = {1長= 2、パス= 0}を与え得ますパスの最初の値..どのように私はそれを得ることができますか?私はこのコードを使用して最後の値を取得することができます

..

NSUInteger lastIndex = [centerCellIndexPath indexAtPosition:[centerCellIndexPath length] - 1]; 

答えて

1

それは非常に簡単です:)

ここ
NSInteger row = centerCellIndexPath.row; 
NSInteger section = centerCellIndexPath.section; 
1

私の作業の答えはボタンのセルインデックスを取得することです。..

CGPoint buttonPosition = [sender convertPoint:CGPointZero 
              toView: self.GlossaryCollView]; 
    NSIndexPath *tappedIP = [self.GlossaryCollView indexPathForItemAtPoint:buttonPosition]; 

    NSInteger *rowIndex = tappedIP.row; 
+0

いい仕事をしています... –

関連する問題