nicklockwood / iCarousel

A simple, highly customisable, data-driven 3D carousel for iOS and Mac OS
http://www.charcoaldesign.co.uk/source/cocoa#icarousel
Other
12.01k stars 2.58k forks source link

presentModalViewController on iCarousel UIView item #211

Closed Mark117 closed 12 years ago

Mark117 commented 12 years ago

Hi Nick,

I've created a carousel with various items, they're all UIViews. What i'm trying to do is perform a transition to a new page using "presentModalViewController". I've read up online and I've read that it's not possible to perform a transition to a new view from within a UIView.

Basically, on one of my carousel items, is a UIView that has a button. I want to navigate to a new view when this button is pressed, but can't since it's a UIView.

Would it be possible to use a ViewController instead of a UIView for the carousel items?

Thanks.

nicklockwood commented 12 years ago

No, but that's not necessary. You can simply bind the actions for the buttons within your item views to a method on your main view controller, and then work out which button it was using the indexOfItemViewOrSubview: method of iCarousel.

You can see an example of this in the Controls Demo, although in that case I am using a nib file for the item views. If you are not using a nib you will need to bind the action programmatically in the viewForItemAtIndex method by saying

[button addTarget:self action:@selector(actionMethod:)

Mark117 commented 12 years ago

Thanks, i'll have a look into this further