summaryrefslogtreecommitdiff
path: root/platform/ios/Classes/MuTextFieldController.m
blob: bc6da40fa4cc4a68fa31830caeb0f7847d32f3ed (plain)
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
#import "MuTextFieldController.h"

@interface MuTextFieldController ()
@property (retain, nonatomic) IBOutlet UINavigationBar *navBar;
- (IBAction)onCancel:(id)sender;
- (IBAction)onOkay:(id)sender;
@property (retain, nonatomic) IBOutlet UITextView *textView;

@end

@implementation MuTextFieldController

-(id)initWithText:(NSString *)text okayAction:(void (^)(NSString *))block
{
	self = [super initWithNibName:@"MuTextFieldController" bundle:nil];
	if (self)
	{
		okayBlock = Block_copy(block);
		initialText = [text retain];
	}
	return self;
}

- (void)viewDidLoad
{
	[super viewDidLoad];
	_textView.text = initialText;
	[_textView becomeFirstResponder];
}

- (void)didReceiveMemoryWarning
{
	[super didReceiveMemoryWarning];
}

- (void)dealloc
{
	[okayBlock release];
	[initialText release];
	[_navBar release];
	[_textView release];
	[super dealloc];
}

- (IBAction)onOkay:(id)sender
{
	okayBlock(_textView.text);
	[self dismissViewControllerAnimated:YES completion:nil];
}

- (IBAction)onCancel:(id)sender
{
	[self dismissViewControllerAnimated:YES completion:nil];
}
@end