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

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

  •  04-10-2022
  •  | 
  •  

Pergunta

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?

Foi útil?

Solução

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]

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top