FreeRDP
Loading...
Searching...
No Matches
EditorBaseController.m
1/*
2 Basic interface for settings editors
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9 */
10
11#import "EditorBaseController.h"
12
13@interface EditorBaseController ()
14
15@end
16
17NSString *TableCellIdentifierText = @"cellIdText";
18NSString *TableCellIdentifierSecretText = @"cellIdSecretText";
19NSString *TableCellIdentifierYesNo = @"cellIdYesNo";
20NSString *TableCellIdentifierSelection = @"cellIdSelection";
21NSString *TableCellIdentifierSubEditor = @"cellIdSubEditor";
22NSString *TableCellIdentifierMultiChoice = @"cellIdMultiChoice";
23
24@implementation EditorBaseController
25
26- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
27{
28 return YES;
29}
30
31#pragma mark - Create table view cells
32- (UITableViewCell *)tableViewCellFromIdentifier:(NSString *)identifier
33{
34 // try to reuse a cell
35 UITableViewCell *cell = [[self tableView] dequeueReusableCellWithIdentifier:identifier];
36 if (cell != nil)
37 return cell;
38
39 // we have to create a new cell
40 if ([identifier isEqualToString:TableCellIdentifierText])
41 {
42 EditTextTableViewCell *textCell =
43 [[[EditTextTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
44 reuseIdentifier:identifier] autorelease];
45 [[textCell textfield] setDelegate:self];
46 cell = textCell;
47 }
48 else if ([identifier isEqualToString:TableCellIdentifierSecretText])
49 {
50 EditSecretTextTableViewCell *secretCell =
51 [[[EditSecretTextTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
52 reuseIdentifier:identifier] autorelease];
53 [[secretCell textfield] setDelegate:self];
54 cell = secretCell;
55 }
56 else if ([identifier isEqualToString:TableCellIdentifierYesNo])
57 {
58 cell = [[[EditFlagTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
59 reuseIdentifier:identifier] autorelease];
60 }
61 else if ([identifier isEqualToString:TableCellIdentifierSelection])
62 {
63 cell = [[[EditSelectionTableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
64 reuseIdentifier:identifier] autorelease];
65 }
66 else if ([identifier isEqualToString:TableCellIdentifierSubEditor])
67 {
68 cell = [[[EditSubEditTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
69 reuseIdentifier:identifier] autorelease];
70 }
71 else if ([identifier isEqualToString:TableCellIdentifierMultiChoice])
72 {
73 cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1
74 reuseIdentifier:identifier] autorelease];
75 }
76 else
77 {
78 NSAssert(false, @"Unknown table cell identifier");
79 }
80
81 return cell;
82}
83
84@end