-
Notifications
You must be signed in to change notification settings - Fork 0
/
EditNoteViewController.m
78 lines (59 loc) · 2.12 KB
/
EditNoteViewController.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
//
// EditNoteViewController.m
// iVerb
//
// Created by Maxime Leroy on 4/2/13.
//
//
#import "EditNoteViewController.h"
@interface EditNoteViewController ()
- (IBAction)cancelAction:(id)sender;
- (IBAction)doneAction:(id)sender;
@end
@implementation EditNoteViewController
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
NSString * nibName = (TARGET_IS_IPAD())? @"EditNoteViewController_Pad" : @"EditNoteViewController_Phone";
if ((self = [super initWithNibName:nibName bundle:[NSBundle mainBundle]])) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:self
action:@selector(cancelAction:)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone
target:self
action:@selector(doneAction:)];
self.title = [NSString stringWithFormat:@"To %@", _verb.infinitif];
self.automaticallyAdjustsScrollViewInsets = NO;
_textView.text = _verb.note;
[_textView becomeFirstResponder];
}
- (void)setVerb:(Verb *)verb
{
_verb = verb;
self.title = _verb.infinitif;
_textView.text = _verb.note;
}
- (IBAction)cancelAction:(id)sender
{
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (IBAction)doneAction:(id)sender
{
_verb.note = _textView.text;
[[NSNotificationCenter defaultCenter] postNotificationName:ResultsDidChangeNotification object:nil];
[self dismissViewControllerAnimated:YES completion:NULL];
}
- (BOOL)shouldAutorotate
{
return (TARGET_IS_IPAD());
}
- (UIInterfaceOrientationMask)supportedInterfaceOrientations
{
return (TARGET_IS_IPAD())? UIInterfaceOrientationMaskAll : UIInterfaceOrientationMaskPortrait;
}
@end