Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 163 lines (132 sloc) 4.908 kb
4633241 @Inferis Initial commit.
authored
1 //
2 // LeftViewController.m
3 // ViewDeckExample
4 //
222e98d @Inferis Fixed copyrights.
authored
5
4633241 @Inferis Initial commit.
authored
6
7 #import "LeftViewController.h"
5422973 @Inferis Left view uses close bound method for demo.
authored
8 #import "IIViewDeckController.h"
4633241 @Inferis Initial commit.
authored
9
10 @implementation LeftViewController
11
12 - (id)initWithStyle:(UITableViewStyle)style
13 {
14 self = [super initWithStyle:style];
15 if (self) {
16 // Custom initialization
17 }
18 return self;
19 }
20
21 - (void)didReceiveMemoryWarning
22 {
23 // Releases the view if it doesn't have a superview.
24 [super didReceiveMemoryWarning];
25
26 // Release any cached data, images, etc that aren't in use.
27 }
28
29 #pragma mark - View lifecycle
30
31 - (void)viewDidLoad
32 {
33 [super viewDidLoad];
121e331 @Inferis Disabled scroll to top so that statusbar tap works again for the center ...
authored
34
35 self.tableView.scrollsToTop = NO;
4633241 @Inferis Initial commit.
authored
36 // Uncomment the following line to preserve selection between presentations.
37 // self.clearsSelectionOnViewWillAppear = NO;
38
39 // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
40 // self.navigationItem.rightBarButtonItem = self.editButtonItem;
41 }
42
43 - (void)viewDidUnload
44 {
45 [super viewDidUnload];
46 // Release any retained subviews of the main view.
47 // e.g. self.myOutlet = nil;
48 }
49
50 - (void)viewWillAppear:(BOOL)animated
51 {
52 [super viewWillAppear:animated];
53 }
54
55 - (void)viewDidAppear:(BOOL)animated
56 {
57 [super viewDidAppear:animated];
58 }
59
60 - (void)viewWillDisappear:(BOOL)animated
61 {
62 [super viewWillDisappear:animated];
63 }
64
65 - (void)viewDidDisappear:(BOOL)animated
66 {
67 [super viewDidDisappear:animated];
68 }
69
70 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
71 {
72 // Return YES for supported orientations
73 return (interfaceOrientation == UIInterfaceOrientationPortrait);
74 }
75
76 #pragma mark - Table view data source
77
78 - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
79 {
eeed688 @Inferis Show more cells in demo tableviews.
authored
80 return 3 + arc4random() % 10;
4633241 @Inferis Initial commit.
authored
81 }
82
83 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
84 {
eeed688 @Inferis Show more cells in demo tableviews.
authored
85 return 3 + arc4random() % 50;
4633241 @Inferis Initial commit.
authored
86 }
87
88 - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
89 return [NSString stringWithFormat:@"%d", section];
90 }
91
92 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
93 {
94 static NSString *CellIdentifier = @"Cell";
95
96 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
97 if (cell == nil) {
98 cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
99 }
100
5422973 @Inferis Left view uses close bound method for demo.
authored
101 cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
4633241 @Inferis Initial commit.
authored
102 cell.textLabel.text = [NSString stringWithFormat:@"%d:%d", indexPath.section, indexPath.row];
103 return cell;
104 }
105
106 /*
107 // Override to support conditional editing of the table view.
108 - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
109 {
110 // Return NO if you do not want the specified item to be editable.
111 return YES;
112 }
113 */
114
115 /*
116 // Override to support editing the table view.
117 - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
118 {
119 if (editingStyle == UITableViewCellEditingStyleDelete) {
120 // Delete the row from the data source
121 [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
122 }
123 else if (editingStyle == UITableViewCellEditingStyleInsert) {
124 // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
125 }
126 }
127 */
128
129 /*
130 // Override to support rearranging the table view.
131 - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
132 {
133 }
134 */
135
136 /*
137 // Override to support conditional rearranging of the table view.
138 - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
139 {
140 // Return NO if you do not want the item to be re-orderable.
141 return YES;
142 }
143 */
144
145 #pragma mark - Table view delegate
146
147 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
148 {
5422973 @Inferis Left view uses close bound method for demo.
authored
149 [tableView deselectRowAtIndexPath:indexPath animated:YES];
150 [self.viewDeckController closeLeftViewBouncing:^(IIViewDeckController *controller) {
c894c2a @Inferis Fixed crashbug in leftcontroller in viewdeck example when the center and...
authored
151 if ([controller.centerController isKindOfClass:[UINavigationController class]]) {
152 UITableViewController* cc = (UITableViewController*)((UINavigationController*)controller.centerController).topViewController;
153 cc.navigationItem.title = [tableView cellForRowAtIndexPath:indexPath].textLabel.text;
c2fa747 @Elegia Fixed a crash bug in LeftViewController.m
Elegia authored
154 if ([cc respondsToSelector:@selector(tableView)]) {
155 [cc.tableView deselectRowAtIndexPath:[cc.tableView indexPathForSelectedRow] animated:NO];
156 }
c894c2a @Inferis Fixed crashbug in leftcontroller in viewdeck example when the center and...
authored
157 }
158 [NSThread sleepForTimeInterval:(300+arc4random()%700)/1000000.0]; // mimic delay... not really necessary
5422973 @Inferis Left view uses close bound method for demo.
authored
159 }];
4633241 @Inferis Initial commit.
authored
160 }
161
162 @end
Something went wrong with that request. Please try again.