-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPSLearningViewController.m
85 lines (69 loc) · 1.96 KB
/
PSLearningViewController.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
//
// PSLearningViewController.m
// PianoScribe
//
// Created by Wenley Tong on 11/4/13.
// Copyright (c) 2013 WenleyTong. All rights reserved.
//
#import "PSLearningViewController.h"
#import "PSInstrumentViewController.h"
@interface PSLearningViewController ()
- (void) finish;
- (void) unloadViewAnimated:(BOOL)animate;
@end
@implementation PSLearningViewController
@synthesize parent;
@synthesize label, startButton, finishedButton;
@synthesize name, directory, database;
- (IBAction) beginLearning:(UIButton *) sender
{
// Swap out buttons
startButton.hidden = YES;
self.database = [[PSNoteDatabase alloc] init];
finishedButton.hidden = NO;
}
/* ---------------------------------------------------------------- */
/* Stop Learning */
/* ---------------------------------------------------------------- */
- (IBAction) finishedLearning:(UIButton *)sender
{
[self finish];
}
- (void) finish
{
// Save learned data to disk
NSString * instrumentWaves = [self.directory stringByAppendingPathComponent:self.name];
[self.database saveDataAtDirectory:instrumentWaves];
[parent loadInstruments]; // Refresh parent's pickerView
[self unloadViewAnimated:NO];
// Load Instrument View
[parent useInstrument:instrumentWaves];
}
- (IBAction) stop:(UIButton *)sender
{
[self unloadViewAnimated:YES];
}
- (void) unloadViewAnimated:(BOOL)animate
{
[parent dismissViewControllerAnimated:animate completion:nil];
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Start with just the start and stop buttons
finishedButton.hidden = YES;
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (UIInterfaceOrientation) preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationLandscapeLeft;
}
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscape;
}
@end