Debian Codegraph @

iOS/Csound iOS Obj-C Examples/Csound iOS Examples/DetailViewController.m

raw
1 /*
2
3 DetailViewController.m:
4
5 Copyright (C) 2011 Steven Yi
6 Updated in 2017 by Dr. Richard Boulanger, Nikhil Singh
7
8 This file is part of Csound iOS Examples.
9
10 The Csound for iOS Library is free software; you can redistribute it
11 and/or modify it under the terms of the GNU Lesser General Public
12 License as published by the Free Software Foundation; either
13 version 2.1 of the License, or (at your option) any later version.
14
15 Csound is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19
20 You should have received a copy of the GNU Lesser General Public
21 License along with Csound; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
23 02111-1307 USA
24
25 */
26
27 #import "DetailViewController.h"
28
29 @interface DetailViewController ()
30 @property (strong, nonatomic) UIViewController *masterPopoverController;
31 - (void)configureView;
32 @end
33
34 @implementation DetailViewController
35
36 #pragma mark - Managing the detail item
37
38 - (void)setDetailItem:(id)newDetailItem
39 {
40 if (_detailItem != newDetailItem) {
41 _detailItem = newDetailItem;
42
43 // Update the view.
44 [self configureView];
45 }
46
47 if (self.masterPopoverController != nil) {
48 [self.masterPopoverController dismissViewControllerAnimated:YES completion:nil];
49 }
50 }
51
52 - (void)configureView
53 {
54 // Update the user interface for the detail item.
55
56 if (self.detailItem) {
57 self.detailDescriptionLabel.text = [self.detailItem description];
58 }
59 }
60
61 - (void)didReceiveMemoryWarning
62 {
63 [super didReceiveMemoryWarning];
64 // Release any cached data, images, etc that aren't in use.
65 }
66
67 #pragma mark - View lifecycle
68
69 - (void)viewDidLoad
70 {
71 [super viewDidLoad];
72 // Do any additional setup after loading the view, typically from a nib.
73 [self configureView];
74 }
75
76 - (void)viewDidUnload
77 {
78 [super viewDidUnload];
79 // Release any retained subviews of the main view.
80 // e.g. self.myOutlet = nil;
81 }
82
83 - (void)viewWillAppear:(BOOL)animated
84 {
85 [super viewWillAppear:animated];
86 }
87
88 - (void)viewDidAppear:(BOOL)animated
89 {
90 [super viewDidAppear:animated];
91 }
92
93 - (void)viewWillDisappear:(BOOL)animated
94 {
95 [super viewWillDisappear:animated];
96 }
97
98 - (void)viewDidDisappear:(BOOL)animated
99 {
100 [super viewDidDisappear:animated];
101 }
102
103 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
104 {
105 // Return YES for supported orientations
106 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
107 return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
108 } else {
109 return YES;
110 }
111 }
112
113 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
114 {
115 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
116 if (self) {
117 self.title = NSLocalizedString(@"Detail", @"Detail");
118 }
119 return self;
120 }
121
122 #pragma mark - Split view
123
124 - (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode
125 {
126 if(displayMode == UISplitViewControllerDisplayModePrimaryHidden ) {
127 self.navigationItem.leftBarButtonItem = svc.displayModeButtonItem;
128 self.navigationItem.leftBarButtonItem.title = NSLocalizedString(@"Master", @"Master");
129 self.masterPopoverController = svc;
130 } else if (displayMode == UISplitViewControllerDisplayModeAllVisible) {
131 [self.navigationItem setLeftBarButtonItem:nil animated:YES];
132 self.masterPopoverController = nil;
133 }
134 }
135
136 @end