Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions Examples/Swift Example/SwiftExample/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,31 +13,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?


func application(application: UIApplication!, didFinishLaunchingWithOptions launchOptions: NSDictionary!) -> Bool {
// Override point for customization after application launch.
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject : AnyObject]?) -> Bool {
return true
}

func applicationWillResignActive(application: UIApplication!) {
func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication!) {
func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication!) {
func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication!) {
func applicationDidBecomeActive(application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication!) {
func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

Expand Down
21 changes: 11 additions & 10 deletions Examples/Swift Example/SwiftExample/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,31 +33,32 @@ class ViewController: UIViewController, iCarouselDataSource, iCarouselDelegate
return items.count
}

func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, var reusingView view: UIView!) -> UIView!

func carousel(carousel: iCarousel!, viewForItemAtIndex index: Int, reusingView view: UIView!) -> UIView!
{
var label: UILabel! = nil

var newView = view
//create new view if no view is available for recycling
if (view == nil)
if (newView == nil)
{
//don't do anything specific to the index within
//this `if (view == nil) {...}` statement because the view will be
//recycled and used with other index values later
view = UIImageView(frame:CGRectMake(0, 0, 200, 200))
(view as UIImageView!).image = UIImage(named: "page.png")
view.contentMode = .Center
newView = UIImageView(frame:CGRectMake(0, 0, 200, 200))
(newView as! UIImageView).image = UIImage(named: "page.png")
newView.contentMode = .Center

label = UILabel(frame:view.bounds)
label = UILabel(frame:newView.bounds)
label.backgroundColor = UIColor.clearColor()
label.textAlignment = .Center
label.font = label.font.fontWithSize(50)
label.tag = 1
view.addSubview(label)
newView.addSubview(label)
}
else
{
//get a reference to the label in the recycled view
label = view.viewWithTag(1) as UILabel!
label = newView.viewWithTag(1) as! UILabel
}

//set item label
Expand All @@ -67,7 +68,7 @@ class ViewController: UIViewController, iCarouselDataSource, iCarouselDelegate
//in the wrong place in the carousel
label.text = "\(items[index])"

return view
return newView
}

func carousel(carousel: iCarousel!, valueForOption option: iCarouselOption, withDefault value: CGFloat) -> CGFloat
Expand Down