Permalink
Browse files

Use UICollectionViewFlowLayout

  • Loading branch information...
1 parent bf9be50 commit 03f544df9af74fdf871a878649c0bf6d2406b1f3 @satococoa committed Feb 27, 2013
Showing with 12 additions and 10 deletions.
  1. +1 −1 app/app_delegate.rb
  2. +11 −1 app/photos_controller.rb
  3. +0 −8 app/photos_layout.rb
View
@@ -5,7 +5,7 @@ def application(application, didFinishLaunchingWithOptions:launchOptions)
NanoStore.shared_store = NanoStore.store(:file, App.documents_path + '/nano.db')
@window = UIWindow.alloc.initWithFrame(App.bounds)
- photos_controller = PhotosController.alloc.initWithCollectionViewLayout(PhotosLayout.new)
+ photos_controller = PhotosController.alloc.initWithCollectionViewLayout(UICollectionViewFlowLayout.new)
navigation_controller = UINavigationController.alloc.initWithRootViewController(photos_controller)
@window.rootViewController = navigation_controller
@window.makeKeyAndVisible
View
@@ -1,19 +1,29 @@
class PhotosController < UICollectionViewController
def viewDidLoad
super
-
navigationItem.title = 'RubyFriends'
+
camera_button = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemCamera, target:self, action:'camera_tapped')
navigationItem.rightBarButtonItem = camera_button
+
open_rubyfriends_button = UIBarButtonItem.alloc.initWithImage(UIImage.imageNamed('icon-ruby.png'), style:UIBarButtonItemStyleBordered, target:self, action:'open_rubyfriends')
spacer = UIBarButtonItem.alloc.initWithBarButtonSystemItem(UIBarButtonSystemItemFlexibleSpace, target:nil, action:nil)
info = UIButton.buttonWithType(UIButtonTypeInfoLight).tap do |b|
b.addTarget(self, action:'open_info', forControlEvents:UIControlEventTouchUpInside)
end
info_button = UIBarButtonItem.alloc.initWithCustomView(info)
self.toolbarItems = [open_rubyfriends_button, spacer, info_button]
+
collectionView.styleId = 'photos'
collectionView.registerClass(FriendCell, forCellWithReuseIdentifier:'friend_cell')
+
+ self.collectionView.collectionViewLayout.tap do |l|
+ l.itemSize = CGSizeMake(128, 128)
+ l.minimumLineSpacing = 20
+ l.minimumInteritemSpacing = 20
+ l.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20)
+ end
+
reload
navigationController.toolbarHidden = false
end
View
@@ -1,8 +0,0 @@
-class PhotosLayout < UICollectionViewFlowLayout
- def prepareLayout
- self.itemSize = CGSizeMake(128, 128)
- self.minimumLineSpacing = 20
- self.minimumInteritemSpacing = 20
- self.sectionInset = UIEdgeInsetsMake(20, 20, 20, 20)
- end
-end

0 comments on commit 03f544d

Please sign in to comment.