我想要一個特定的部分indexPath
,但這段代碼只給我第0部分indexPath
,因爲InSection
我設置了0. 如果有多個部分,那麼我怎麼得到indexPath
?獲取具有多個部分的行和部分的索引?
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0];
幫助我。
我想要一個特定的部分indexPath
,但這段代碼只給我第0部分indexPath
,因爲InSection
我設置了0. 如果有多個部分,那麼我怎麼得到indexPath
?獲取具有多個部分的行和部分的索引?
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection: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);
}
sender
上的tag
屬性正在返回它的默認值。
確保您sender
創作過程中適當設置tag
,應設置爲:
myView.tag = indexPath
現在,sender
而這樣做將返回正確的indexPath
值:
NSIndexPath *indexPath = [NSIndexPath indexPathForRow:[sender tag] inSection:0];
只是確保標記設置正確(我猜在cellForRowAtIndexpath :)來檢索正確的索引。
感謝man..Its工作.. –