I am working on a food ordering app and creating the menu page using iCarousel with cards like Card Image. As I want the buttons in cards to add or delete product and scroll view for product description. So can anyone help me out as how can I implement this feature or is there any other alternative for this ??
Asked
Active
Viewed 965 times
1 Answers
1
Download the iCarousel project: https://github.com/nicklockwood/iCarousel
Add the iCarousel.h
and iCarousel.m
files to your Swift project.
Xcode will prompt you to add a bridge-header. Select ok
In the bridge-header:
#import "iCarousel.h"
Add a UIView
to your storyboard. Set the type to iCarousel
.
Connect the view to your code.
@IBOutlet var carouselView: iCarousel!
Add the iCarouselDelegate
and iCarouselDataSource
to your view controller.
Then add the following methods:
func numberOfItems(in carousel: iCarousel) -> Int {
return 1//Or however many views you want
}
func carousel(_ carousel: iCarousel, viewForItemAt index: Int, reusing view: UIView?) -> UIView {
//Create a UIView programmatically and return it
}
Lastly, add the following in viewDidLoad
or viewDidAppear
:
carouselView.delegate = self
carouselView.dataSource = self
carouselView.reloadData()

Pranav Wadhwa
- 7,666
- 6
- 39
- 61
-
Thanks, it helped a lot ... But how can i have multiple views with buttons (2 or 3 on each view) and each with different functionality ?? So I was thinking of designing views independently and then using them with iCarousel, is it even possible as I am completely new to this and having not a single clue about its implementation – Amol Kumar Jul 09 '16 at 12:22
-
Create an array called returnViews. Add all of your views to the array. Then `return returnViews[index]` – Pranav Wadhwa Jul 09 '16 at 12:27
-
Its giving me this error- fatal error: unexpectedly found nil while unwrapping an Optional value (lldb) – Amol Kumar Jul 09 '16 at 12:39
-
To debug: http://stackoverflow.com/questions/32170456/what-does-fatal-error-unexpectedly-found-nil-while-unwrapping-an-optional-valu – Pranav Wadhwa Jul 09 '16 at 12:49