-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSLSTextViewController.m
executable file
·110 lines (86 loc) · 2.87 KB
/
SLSTextViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
//
// SLSTextViewController.m
// Molecules
//
// The source code for Molecules is available under a BSD license. See License.txt for details.
//
// Created by Brad Larson on 6/30/2008.
//
// This class is based on Apple's example from the Recipes sample application, with only minor modifications
#import "SLSTextViewController.h"
#import "SLSCellTextView.h"
@implementation SLSTextViewController
#define kUITextViewCellRowHeight 390.0f
- (id)initWithTitle:(NSString *)newTitle andContent:(NSString *)newContent;
{
if (self = [super initWithStyle:UITableViewStyleGrouped])
{
// this title will appear in the navigation bar
self.title = newTitle;
content = [newContent retain];
}
return self;
}
- (void)dealloc
{
[content release];
[super dealloc];
}
- (UITextView *)create_UITextView
{
CGRect frame = CGRectMake(0.0f, 0.0f, 100.0f, 390.0f);
UITextView *textView = [[[UITextView alloc] initWithFrame:frame] autorelease];
textView.textColor = [UIColor blackColor];
textView.font = [UIFont fontWithName:@"Arial" size:18.0];
textView.backgroundColor = [UIColor whiteColor];
textView.showsVerticalScrollIndicator = YES;
textView.editable = NO;
textView.text = content;
// note: for UITextView, if you don't like autocompletion while typing use:
// myTextView.autocorrectionType = UITextAutocorrectionTypeNo;
return textView;
}
#pragma mark - UITableView delegates
// if you want the entire table to just be re-orderable then just return UITableViewCellEditingStyleNone
//
- (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath
{
return UITableViewCellEditingStyleNone;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
//{
// return @"UITextView";
//}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
// to determine specific row height for each cell, override this. In this example, each row is determined
// buy the its subviews that are embedded.
//
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return kUITextViewCellRowHeight;
}
// to determine which UITableViewCell to be used on a given row.
//
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kSLSCellTextView_ID];
if (cell == nil)
{
cell = [[[SLSCellTextView alloc] initWithFrame:CGRectZero reuseIdentifier:kSLSCellTextView_ID] autorelease];
}
// this cell hosts the UISwitch control
((SLSCellTextView *)cell).view = [self create_UITextView];
return cell;
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
@end