Need to create an NSIndexPath for iCarousel to pass info to additional view controllers

StackOverflow https://stackoverflow.com/questions/21416073

  •  04-10-2022
  •  | 
  •  

문제

I'm implementing an iCarousel that should pass information based on selection made to two additional view controllers.

To pass the information I understand that I need to create an NSIndexPath in the prepareForSegue method in the view controller that contains the iCarousel. The problem I'm having is creating an NSIndexPath since the carousel does not have rows.

In a tableview situation I could use the following:

NSIndexPath *path = [self.tableview indexPathForSelectedRow];

Can I simply change "tableview" to "carousel" and use something in place of indexPathForSelectedRow or is it more complicated than that?

도움이 되었습니까?

해결책

As for creating the indexPath object: You can create an indexPath with the

NSIndexPath * indexPath = [NSIndexPath indexPathForRow:itemID inSection:0];

Giving a 0 value to the section index would not matter since, as you point out, there is no section in the carrousel

Finding the index for the itemID, if you use the nicklockwood's iCarousel :

int itemId = [self.myCarroussel currentItemIndex]

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top