Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 95 lines (81 sloc) 2.664 kB
fbab5c2 Added blog files
Jeff LaMarche authored
1 //
2 // LongTextFieldViewController.m
3 // iContractor
4 //
5 // Created by Jeff LaMarche on 2/10/09.
6 // Copyright 2009 Jeff LaMarche Consulting. All rights reserved.
7 //
8
9 #import "LongTextFieldViewController.h"
10
11
12 @implementation LongTextFieldViewController
13 @synthesize string;
14 @synthesize textView;
15 @synthesize delegate;
16 - (void)save
17 {
18 [self.delegate takeNewString:textView.text];
19 [self.navigationController popViewControllerAnimated:YES];
20 }
21 #pragma mark -
22 - (void)viewDidLoad
23 {
24 [super viewDidLoad];
25 }
26 - (void)viewWillAppear:(BOOL)animated
27 {
28
29
30 NSUInteger firstRowIndices[] = {0,0};
31 NSIndexPath *firstRowPath = [NSIndexPath indexPathWithIndexes:firstRowIndices length:2];
32 UITableViewCell *firstCell = [self.tableView cellForRowAtIndexPath:firstRowPath];
33 UITextView *firstCellTextField = nil;
34 for (UIView *oneView in firstCell.contentView.subviews)
35 {
36 if ([oneView isMemberOfClass:[UITextView class]])
37 firstCellTextField = (UITextView *)oneView;
38 }
39 [firstCellTextField becomeFirstResponder];
40
41 [super viewWillAppear:animated];
42 }
43 - (void)dealloc
44 {
45 [string release];
46 [textView release];
47 [super dealloc];
48 }
49
50 #pragma mark Tableview methods
51 - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
52 {
53 return 1;
54 }
55 // Customize the appearance of table view cells.
56 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
57 {
58
59 static NSString *LongTextFieldCellIdentifier = @"LongTextFieldCellIdentifier";
60
61 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:LongTextFieldCellIdentifier];
62 if (cell == nil)
63 {
64 cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:LongTextFieldCellIdentifier] autorelease];
65 UITextView *theTextView = [[UITextView alloc] initWithFrame:CGRectMake(10.0, 10.0, 280.0, 161.0)];
66 theTextView.editable = YES;
67 theTextView.text = string;
68 theTextView.font = [UIFont systemFontOfSize:14.0];
69 [theTextView becomeFirstResponder];
70 self.textView = theTextView;
71 [[cell contentView] addSubview:theTextView];
72 [theTextView release];
73 }
74 // This doesn't work - no matter where I put it. It's almost as if this property is readonly
75 textView.selectedRange = NSMakeRange([string length], 0);;
76
77
78 return cell;
79 }
80
81 - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath
82 {
83 return nil;
84 }
85 - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
86 {
87 // Nothing for now
88 }
89 - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
90 {
91 return 181.0;
92 }
93 @end
94
Something went wrong with that request. Please try again.