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