Permalink
Browse files

Completed event handling. Revisited Demo.

  • Loading branch information...
René Sprotte
René Sprotte committed Apr 4, 2011
1 parent be5808d commit 9900b6fabd7ae6308cf78052a11fa486d682bc27
@@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
+ 7E63973B1349CED300823606 /* AnyViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7E6397381349CAEA00823606 /* AnyViewController.xib */; };
+ 7E63973C1349CED900823606 /* AnyViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E6397371349CAEA00823606 /* AnyViewController.m */; };
7E6EF37C1340A48600DD91EC /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 7E6EF37B1340A48600DD91EC /* Foundation.framework */; };
7E6EF3A91340A53100DD91EC /* MMGridView.h in Headers */ = {isa = PBXBuildFile; fileRef = 7E6EF3A71340A53100DD91EC /* MMGridView.h */; };
7E6EF3AA1340A53100DD91EC /* MMGridView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E6EF3A81340A53100DD91EC /* MMGridView.m */; };
@@ -35,6 +37,9 @@
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
+ 7E6397361349CAEA00823606 /* AnyViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AnyViewController.h; sourceTree = "<group>"; };
+ 7E6397371349CAEA00823606 /* AnyViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AnyViewController.m; sourceTree = "<group>"; };
+ 7E6397381349CAEA00823606 /* AnyViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = AnyViewController.xib; sourceTree = "<group>"; };
7E6EF3781340A48600DD91EC /* libMMGridView.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libMMGridView.a; sourceTree = BUILT_PRODUCTS_DIR; };
7E6EF37B1340A48600DD91EC /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
7E6EF37F1340A48600DD91EC /* MMGridView-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MMGridView-Prefix.pch"; sourceTree = "<group>"; };
@@ -139,6 +144,9 @@
7E6EF3DC1340B52E00DD91EC /* RootViewController.h */,
7E6EF3DD1340B52E00DD91EC /* RootViewController.m */,
7E6EF3DF1340B52E00DD91EC /* RootViewController.xib */,
+ 7E6397361349CAEA00823606 /* AnyViewController.h */,
+ 7E6397371349CAEA00823606 /* AnyViewController.m */,
+ 7E6397381349CAEA00823606 /* AnyViewController.xib */,
);
path = MMGridViewDemo;
sourceTree = "<group>";
@@ -238,6 +246,7 @@
7E6EF3D21340B52E00DD91EC /* InfoPlist.strings in Resources */,
7E6EF3DB1340B52E00DD91EC /* MainWindow.xib in Resources */,
7E6EF3E11340B52E00DD91EC /* RootViewController.xib in Resources */,
+ 7E63973B1349CED300823606 /* AnyViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -260,6 +269,7 @@
7E6EF3D51340B52E00DD91EC /* main.m in Sources */,
7E6EF3D81340B52E00DD91EC /* AppDelegate.m in Sources */,
7E6EF3DE1340B52E00DD91EC /* RootViewController.m in Sources */,
+ 7E63973C1349CED900823606 /* AnyViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -26,7 +26,9 @@
#pragma - MMGridViewDelegate
@protocol MMGridViewDelegate<NSObject>
-- (void)gridView:(MMGridView *)gridView didSelectAtIndex:(NSInteger)index;
+@optional
+- (void)gridView:(MMGridView *)gridView didSelectCell:(MMGridViewCell *)cell atIndex:(NSInteger)index;
+- (void)gridView:(MMGridView *)gridView didDoubleTappedCell:(MMGridViewCell *)cell atIndex:(NSInteger)index;
@end
// ----------------------------------------------------------------------------------
@@ -39,7 +41,6 @@
UIScrollView *scrollView;
UIPageControl *pageControl;
UIView *pageControlBackgroundView;
- UIView *view;
id<MMGridViewDataSource> dataSource;
id<MMGridViewDelegate> delegate;
NSUInteger numberOfRows;
@@ -139,6 +139,8 @@ - (void)reloadData
for (NSInteger i = 0; i < numberOfCells; i++) {
MMGridViewCell *cell = [self.dataSource gridView:self cellAtIndex:i];
[cell performSelector:@selector(setGridView:) withObject:self];
+ [cell performSelector:@selector(setIndex:) withObject:[NSNumber numberWithInt:i]];
+
NSInteger page = (int)floor((float)i / (float)cellsPerPage);
NSInteger row = (int)floor((float)i / (float)noOfCols) - (page * noOfRows);
@@ -157,13 +159,17 @@ - (void)reloadData
- (void)cellWasSelected:(MMGridViewCell *)cell
{
- NSLog(@"Cell was selected");
+ if (delegate) {
+ [delegate gridView:self didSelectCell:cell atIndex:[cell.index intValue]];
+ }
}
- (void)cellWasDoubleTapped:(MMGridViewCell *)cell
{
- NSLog(@"Cell was double tapped");
+ if (delegate) {
+ [delegate gridView:self didDoubleTappedCell:cell atIndex:[cell.index intValue]];
+ }
}
@end
@@ -16,11 +16,13 @@
UIView *textLabelBackgroundView;
UIView *backgroundView;
MMGridView *gridView;
+ NSNumber *index;
}
@property (nonatomic, retain) UILabel *textLabel;
@property (nonatomic, retain) UIView *textLabelBackgroundView;
@property (nonatomic, retain) UIView *backgroundView;
@property (nonatomic, readonly) MMGridView *gridView;
+@property (nonatomic, readonly) NSNumber *index;
@end
@@ -11,6 +11,7 @@
@interface MMGridViewCell()
@property (nonatomic, assign) MMGridView *gridView;
+@property (nonatomic, assign) NSNumber *index;
@end
@@ -20,6 +21,7 @@ @implementation MMGridViewCell
@synthesize textLabelBackgroundView;
@synthesize backgroundView;
@synthesize gridView;
+@synthesize index;
- (void)dealloc
{
@@ -0,0 +1,16 @@
+//
+// AnyViewController.h
+// MMGridView
+//
+// Created by René Sprotte on 04.04.11.
+// Copyright 2011 metaminded. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface AnyViewController : UIViewController {
+
+}
+
+@end
@@ -0,0 +1,57 @@
+//
+// AnyViewController.m
+// MMGridView
+//
+// Created by René Sprotte on 04.04.11.
+// Copyright 2011 metaminded. All rights reserved.
+//
+
+#import "AnyViewController.h"
+
+
+@implementation AnyViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self) {
+ // Custom initialization
+ }
+ return self;
+}
+
+- (void)dealloc
+{
+ [super dealloc];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc that aren't in use.
+}
+
+#pragma mark - View lifecycle
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view from its nib.
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ // Return YES for supported orientations
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+@end
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="7.10">
+ <data>
+ <int key="IBDocument.SystemTarget">1056</int>
+ <string key="IBDocument.SystemVersion">10J869</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1305</string>
+ <string key="IBDocument.AppKitVersion">1038.35</string>
+ <string key="IBDocument.HIToolboxVersion">461.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">300</string>
+ </object>
+ <object class="NSArray" key="IBDocument.IntegratedClassDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>IBProxyObject</string>
+ <string>IBUIView</string>
+ <string>IBUILabel</string>
+ </object>
+ <object class="NSArray" key="IBDocument.PluginDependencies">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys" id="0">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ </object>
+ <reference key="dict.values" ref="0"/>
+ </object>
+ <object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBProxyObject" id="975951072">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="191373211">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">274</int>
+ <object class="NSMutableArray" key="NSSubviews">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBUILabel" id="268360317">
+ <reference key="NSNextResponder" ref="191373211"/>
+ <int key="NSvFlags">301</int>
+ <string key="NSFrame">{{124, 220}, {72, 21}}</string>
+ <reference key="NSSuperview" ref="191373211"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
+ <int key="IBUIContentMode">7</int>
+ <bool key="IBUIUserInteractionEnabled">NO</bool>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <string key="IBUIText">Any View</string>
+ <object class="NSFont" key="IBUIFont">
+ <string key="NSName">Helvetica</string>
+ <double key="NSSize">17</double>
+ <int key="NSfFlags">16</int>
+ </object>
+ <object class="NSColor" key="IBUITextColor">
+ <int key="NSColorSpace">1</int>
+ <bytes key="NSRGB">MCAwIDAAA</bytes>
+ </object>
+ <nil key="IBUIHighlightedColor"/>
+ <int key="IBUIBaselineAdjustment">1</int>
+ <float key="IBUIMinimumFontSize">10</float>
+ </object>
+ </object>
+ <string key="NSFrame">{{0, 20}, {320, 460}}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <reference key="NSNextKeyView" ref="268360317"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ </object>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <object class="NSMutableArray" key="connectionRecords">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="191373211"/>
+ </object>
+ <int key="connectionID">3</int>
+ </object>
+ </object>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <object class="NSArray" key="orderedObjects">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <reference key="object" ref="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1</int>
+ <reference key="object" ref="191373211"/>
+ <object class="NSMutableArray" key="children">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference ref="268360317"/>
+ </object>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="975951072"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">4</int>
+ <reference key="object" ref="268360317"/>
+ <reference key="parent" ref="191373211"/>
+ </object>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="flattenedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="NSArray" key="dict.sortedKeys">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>-1.CustomClassName</string>
+ <string>-2.CustomClassName</string>
+ <string>1.IBEditorWindowLastContentRect</string>
+ <string>1.IBPluginDependency</string>
+ <string>4.IBPluginDependency</string>
+ </object>
+ <object class="NSMutableArray" key="dict.values">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <string>AnyViewController</string>
+ <string>UIResponder</string>
+ <string>{{556, 412}, {320, 480}}</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </object>
+ </object>
+ <object class="NSMutableDictionary" key="unlocalizedProperties">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <reference key="dict.values" ref="0"/>
+ </object>
+ <nil key="activeLocalization"/>
+ <object class="NSMutableDictionary" key="localizations">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <reference key="dict.sortedKeys" ref="0"/>
+ <reference key="dict.values" ref="0"/>
+ </object>
+ <nil key="sourceID"/>
+ <int key="maxID">4</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <object class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <bool key="EncodedWithXMLCoder">YES</bool>
+ <object class="IBPartialClassDescription">
+ <string key="className">AnyViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/AnyViewController.h</string>
+ </object>
+ </object>
+ </object>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3</string>
+ <integer value="3000" key="NS.object.0"/>
+ </object>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">300</string>
+ </data>
+</archive>
Oops, something went wrong.

0 comments on commit 9900b6f

Please sign in to comment.