Cover Flow

Coverflow is free, third-party software. Tap on the partially hidden animals.

Source code in Flow.zip

Each album cover is an AFItemView object. The AFItemViews are subviews of one big AFOpenFlowView. The AFOpenFlowView is under a CoverFlowViewController. There are no view controllers under this view controller. AF stands for the author, Alex Fajkowski.

  1. main.m
  2. Class FlowAppDelegate: window background is lightGrayColor.
  3. Class CoverFlowViewController
  4. AFOpenFlowConstants.h
  5. Class AFOpenFlowView
  6. Class AFItemView contains one image.
  7. Class AFUIImageReflection
  8. Flow-Info.plist
  9. cover_0.jpg kitten
  10. cover_1.jpg cow
  11. cover_2.jpg dog
  12. cover_3.jpg duck
  13. cover_4.jpg horse
  14. cover_5.jpg frog
  15. cover_6.jpg pig
  16. cover_7.jpg chicken
  17. cover_8.jpg sheep
  18. cover_9.jpg howling wolf profile, black on white

Create the project

Follow these instructions. Download the following seven source files from GitHub by pressing the “Download ZIP” button on the lower right. The seven files are in the OpenFlow folder of the OpenFlow-master folder you downloaded from GitHub. Drag the files to the Flow folder of the project.
Choose options for adding these files.
Destination ☑ Copy items into destionation group’s folder (if required).

For iOS 7 with Automatic Reference Counting, we have to remove every call to the methods retain, release, autorelease, and dealloc in the seven files. See how I removed them or commented them out in the above project.

  1. AFOpenFlowConstants.h
  2. AFOpenFlowView.h
  3. AFOpenFlowView.m
  4. AFItemView.h
  5. AFItemView.m
  6. AFUIImageReflection.h
  7. AFUIImageReflection.m

Drag the following ten .jpg files into the Supporting Files folder of the project.
Choose options for adding these files.
Destination ☑ Copy items into destionation group’s folder (if required).

  1. cover_0.jpg kitten
  2. cover_1.jpg cow
  3. cover_2.jpg dog
  4. cover_3.jpg duck
  5. cover_4.jpg horse
  6. cover_5.jpg frog
  7. cover_6.jpg pig
  8. cover_7.jpg chicken
  9. cover_8.jpg sheep
  10. cover_9.jpg howling wolf profile, back on white

Weak pointers

The CoverFlowViewController and the AFOpenFlowView contain pointers to each other. The dataSource and viewDelegate instance variables and properties of the AFOpenFlowView must therefore be weak pointers. See the View Controller project, where this problem first came up.

Missing getters

The numberOfImages property in class AFOpenFlowView has a setter method (setNumberOfImages:) but no getter. Add the following getter.

- (int) numberOfImages {
	return numberOfImages;
}

Do the same for the number property of class AFItemView.

- (int) number {
	return number;
}

Landscape orientation

In the method setUpInitialState in AFOpenFlowView.m, change

	scrollView = [[UIScrollView alloc] initWithFrame: self.frame];
to
	scrollView = [[UIScrollView alloc] initWithFrame: self.bounds];
This will allow the AFOpenFlowView to extend into the rightmost 20 pairs of pixels of the window.

Add Initial Interface Orientation Landscape (left home button) to Flow-Info.plist.

Select the project Flow in the Project Navigator. In the center panel of Xcode,
Deployment Info → Device Orientation
Uncheck Portrait.

Miscellaneous

In AFUIImageReflection.m, cast the CGImageAlphaInfo enumeration kCGImageAlphaNone to (CGBitmapInfo)kCGImageAlphaNone.

The last step in the instructions involves the CoverflowViewController.xib file. Since I skipped this step (I hate the Interface Builder), I had to write a loadView method in my class CoverFlowViewController. I also had to add the following statement to the application:didFinishLaunchingWithOptions: method of the application delegate.

	self.window.backgroundColor = [UIColor lightGrayColor];

Things to try

  1. Interested in studying the animation? Let’s slow it down so we can see it better. Insert the following statement immediately after the call to beginAnimations:context: in AFOpenFlowView.m. See “Animation in iOS 3” here.
    		[UIView setAnimationDuration: 3.0];	//3 seconds