Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Unified Diff: ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.mm

Issue 2592593003: Upstream ios/showcase source code. (Closed)
Patch Set: Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.mm
diff --git a/ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.mm b/ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.mm
new file mode 100644
index 0000000000000000000000000000000000000000..71a496b21bb4140a39f4191648c464ce8964abc2
--- /dev/null
+++ b/ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.mm
@@ -0,0 +1,65 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#import "ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.h"
+
+#if !defined(__has_feature) || !__has_feature(objc_arc)
+#error "This file requires ARC support."
+#endif
+
+@implementation UIKitTableViewCellViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ self.tableView.tableFooterView = [[UIView alloc] init];
+ self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
+}
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView*)tableView {
+ return 4;
+}
+
+- (NSInteger)tableView:(UITableView*)tableView
+ numberOfRowsInSection:(NSInteger)section {
+ return 1;
+}
+
+- (NSString*)tableView:(UITableView*)tableView
+ titleForHeaderInSection:(NSInteger)section {
+ switch ([self styleForSection:section]) {
+ case UITableViewCellStyleDefault:
+ return @"Default Style";
+ case UITableViewCellStyleValue1:
+ return @"Value 1 Style";
+ case UITableViewCellStyleValue2:
+ return @"Value 2 Style";
+ case UITableViewCellStyleSubtitle:
+ return @"Subtitle Style";
+ }
+}
+
+- (UITableViewCell*)tableView:(UITableView*)tableView
+ cellForRowAtIndexPath:(NSIndexPath*)indexPath {
+ UITableViewCellStyle style = [self styleForSection:indexPath.section];
+ NSString* reuseIdentifier = @(style).stringValue;
+ UITableViewCell* cell =
+ [tableView dequeueReusableCellWithIdentifier:reuseIdentifier];
+ if (!cell) {
+ cell = [[UITableViewCell alloc] initWithStyle:style
+ reuseIdentifier:reuseIdentifier];
+ }
+ cell.textLabel.text = @"Text";
+ cell.detailTextLabel.text = @"Detail Text";
+ return cell;
+}
+
+#pragma mark - Private
+
+- (UITableViewCellStyle)styleForSection:(NSInteger)section {
+ NSAssert(section >= 0, @"");
+ NSAssert(section < 4, @"");
+ return (UITableViewCellStyle)section;
+}
+
+@end
« no previous file with comments | « ios/showcase/uikit_table_view_cell/uikit_table_view_cell_view_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698