1
1
class <%= @name_camel_case %>Controller < UICollectionViewController
2
- # In app_delegate.rb or wherever you use this controller, just call #new like so:
3
- # @window.rootViewController = <%= @name_camel_case %> Controller . new
2
+ # In app_delegate.rb or wherever you use this controller, just call .new like so:
3
+ # @window.rootViewController = <%= @name_camel_case %> Controller . new
4
+ #
5
+ # Or if you're adding using it in a navigation controller, do this
6
+ # main_controller = <%= @name_camel_case %>Controller.new
7
+ # @window.rootViewController = UINavigationController.alloc.initWithRootViewController(main_controller)
4
8
9
+ <%= @name . upcase %>_CELL_ID = "<%= @name_camel_case %> Cell "
10
+
5
11
def self.new(args = {})
6
12
# Set layout
7
13
layout = UICollectionViewFlowLayout.alloc.init
@@ -14,7 +20,7 @@ def viewDidLoad
14
20
rmq.stylesheet = <%= @name_camel_case %>ControllerStylesheet
15
21
16
22
collectionView.tap do |cv|
17
- cv.registerClass(<%= @name_camel_case %> Cell , forCellWithReuseIdentifier : <%= @name_camel_case %>Cell.name )
23
+ cv.registerClass(<%= @name_camel_case %>Cell, forCellWithReuseIdentifier: <%= @name.upcase %>_CELL_ID )
18
24
cv.delegate = self
19
25
cv.dataSource = self
20
26
cv.allowsSelection = true
@@ -30,27 +36,28 @@ def supportedInterfaceOrientations
30
36
31
37
# Remove if you are only supporting portrait
32
38
def willAnimateRotationToInterfaceOrientation(orientation, duration: duration)
33
- rmq.all .reapply_styles
39
+ rmq(:reapply_style) .reapply_styles
34
40
end
35
41
36
42
def numberOfSectionsInCollectionView(view)
37
43
1
38
44
end
39
45
40
46
def collectionView(view, numberOfItemsInSection: section)
41
- 40
47
+ 200
42
48
end
43
49
44
50
def collectionView(view, cellForItemAtIndexPath: index_path)
45
- view.dequeueReusableCellWithReuseIdentifier(<%= @name_camel_case %> Cell . name , forIndexPath : index_path ) . tap do |cell |
51
+ view.dequeueReusableCellWithReuseIdentifier(<%= @name.upcase %>_CELL_ID , forIndexPath: index_path).tap do |cell|
46
52
cell.setup_with(rmq)
47
53
48
54
# Update cell's data here
49
55
end
50
56
end
51
57
52
58
def collectionView(view, didSelectItemAtIndexPath: index_path)
53
- cell = collectionView . cellForItemAtIndexPath ( index_path )
59
+ cell = view.cellForItemAtIndexPath(index_path)
60
+ puts " Selected at section : #{index_path.section}, row: #{index_path.row}"
54
61
end
55
62
56
63
end
0 commit comments