Browse files

Changed central view controller to tableview to show scrolling still …

…works.
  • Loading branch information...
1 parent 4633241 commit a02f9da02d61a4a19f5b54fe66367612ca49d594 @Inferis Inferis committed Dec 5, 2011
View
4 ViewDeckExample/ViewController.h
@@ -2,12 +2,12 @@
// ViewController.h
// ViewDeckExample
//
-// Created by Tom Adriaenssen on 03/12/11.
+// Created by Tom Adriaenssen on 04/12/11.
// Copyright (c) 2011 Adriaenssen BVBA. All rights reserved.
//
#import <UIKit/UIKit.h>
-@interface ViewController : UIViewController
+@interface ViewController : UITableViewController
@end
View
72 ViewDeckExample/ViewController.m
@@ -2,7 +2,7 @@
// ViewController.m
// ViewDeckExample
//
-// Created by Tom Adriaenssen on 03/12/11.
+// Created by Tom Adriaenssen on 04/12/11.
// Copyright (c) 2011 Adriaenssen BVBA. All rights reserved.
//
@@ -11,12 +11,29 @@
@implementation ViewController
+- (id)initWithStyle:(UITableViewStyle)style
+{
+ self = [super initWithStyle:style];
+ if (self) {
+ // Custom initialization
+ }
+ return self;
+}
+
+- (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];
-
+
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"left" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleLeftView)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"right" style:UIBarButtonItemStyleBordered target:self.viewDeckController action:@selector(toggleRightView)];
}
@@ -40,18 +57,63 @@ - (void)viewDidAppear:(BOOL)animated
- (void)viewWillDisappear:(BOOL)animated
{
- [super viewWillDisappear:animated];
+ [super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
- [super viewDidDisappear:animated];
+ [super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
- return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+#pragma mark - Table view data source
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 3 + arc4random() % 5;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ return 3 + arc4random() % 5;
+}
+
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
+ return [NSString stringWithFormat:@"%d", section];
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+ cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
+ }
+
+ cell.textLabel.textAlignment = UITextAlignmentCenter;
+ cell.textLabel.text = [NSString stringWithFormat:@"%d:%d", indexPath.section, indexPath.row];
+
+ return cell;
+}
+
+
+#pragma mark - Table view delegate
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // Navigation logic may go here. Create and push another view controller.
+ /*
+ <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
+ // ...
+ // Pass the selected object to the new view controller.
+ [self.navigationController pushViewController:detailViewController animated:YES];
+ */
}
@end
View
47 ViewDeckExample/en.lproj/ViewController.xib → ViewDeckExample/ViewController.xib
@@ -12,7 +12,7 @@
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>IBProxyObject</string>
- <string>IBUIView</string>
+ <string>IBUITableView</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
@@ -26,26 +26,33 @@
<string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
- <object class="IBProxyObject" id="843779117">
+ <object class="IBProxyObject" id="975951072">
<string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
- <object class="IBUIView" id="774585933">
+ <object class="IBUITableView" id="873029372">
<reference key="NSNextResponder"/>
<int key="NSvFlags">274</int>
<string key="NSFrame">{{0, 20}, {320, 460}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
+ <reference key="NSNextKeyView"/>
<object class="NSColor" key="IBUIBackgroundColor">
<int key="NSColorSpace">3</int>
- <bytes key="NSWhite">MC43NQA</bytes>
- <object class="NSColorSpace" key="NSCustomColorSpace">
- <int key="NSID">2</int>
- </object>
+ <bytes key="NSWhite">MQA</bytes>
</object>
+ <bool key="IBUIOpaque">NO</bool>
+ <bool key="IBUIClipsSubviews">YES</bool>
<bool key="IBUIClearsContextBeforeDrawing">NO</bool>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <bool key="IBUIBouncesZoom">NO</bool>
+ <int key="IBUISeparatorStyle">1</int>
+ <int key="IBUISectionIndexMinimumDisplayRowCount">0</int>
+ <bool key="IBUIShowsSelectionImmediatelyOnTouchBegin">YES</bool>
+ <float key="IBUIRowHeight">44</float>
+ <float key="IBUISectionHeaderHeight">22</float>
+ <float key="IBUISectionFooterHeight">22</float>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
@@ -54,7 +61,23 @@
<object class="IBCocoaTouchOutletConnection" key="connection">
<string key="label">view</string>
<reference key="source" ref="372490531"/>
- <reference key="destination" ref="774585933"/>
+ <reference key="destination" ref="873029372"/>
+ </object>
+ <int key="connectionID">5</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">dataSource</string>
+ <reference key="source" ref="873029372"/>
+ <reference key="destination" ref="372490531"/>
+ </object>
+ <int key="connectionID">6</int>
+ </object>
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">delegate</string>
+ <reference key="source" ref="873029372"/>
+ <reference key="destination" ref="372490531"/>
</object>
<int key="connectionID">7</int>
</object>
@@ -75,12 +98,12 @@
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
- <reference key="object" ref="843779117"/>
+ <reference key="object" ref="975951072"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
- <int key="objectID">6</int>
- <reference key="object" ref="774585933"/>
+ <int key="objectID">4</int>
+ <reference key="object" ref="873029372"/>
<reference key="parent" ref="0"/>
</object>
</array>
@@ -90,7 +113,7 @@
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
<string key="-2.CustomClassName">UIResponder</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
- <string key="6.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>

0 comments on commit a02f9da

Please sign in to comment.