1/* 2 3 BaseCsoundViewController.m: 4 5 Copyright (C) 2014 Steven Yi, Aurelius Prochazka 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 "BaseCsoundViewController.h" 28 29@interface BaseCsoundViewController () 30- (void)configureView; 31@end 32 33@implementation BaseCsoundViewController 34 35#pragma mark - Managing the detail item 36 37- (void)setDetailItem:(id)newDetailItem 38{ 39 if (_detailItem != newDetailItem) { 40 self.detailItem = newDetailItem; 41 42 // Update the view. 43 [self configureView]; 44 } 45 46 if (self.masterPopoverController != nil) { 47 [self.masterPopoverController dismissViewControllerAnimated:YES completion:nil]; 48 } 49} 50 51- (void)configureView 52{ 53 // Update the user interface for the detail item. 54 55 if (self.detailItem) { 56 self.detailDescriptionLabel.text = [self.detailItem description]; 57 } 58} 59 60 61-(void)viewWillDisappear:(BOOL)animated { 62 63 [super viewWillDisappear:animated]; 64 65 [self.csound stop]; 66} 67 68- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 69{ 70 // Return YES for supported orientations 71 if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) { 72 return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 73 } else { 74 return YES; 75 } 76} 77 78- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 79{ 80 self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 81 if (self) { 82 self.title = NSLocalizedString(@"Detail", @"Detail"); 83 } 84 return self; 85} 86 87-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller { 88 return UIModalPresentationNone; 89} 90 91-(UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection { 92 return UIModalPresentationNone; 93} 94 95-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 96 [segue destinationViewController].modalPresentationStyle = UIModalPresentationPopover; 97} 98 99#pragma mark - Split view 100 101- (void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode 102{ 103 self.navigationItem.leftBarButtonItem = [self splitViewController].displayModeButtonItem; 104 self.navigationItem.leftBarButtonItem.title = @"Csound for iOS"; 105 self.masterPopoverController = svc; 106 107} 108 109- (void)splitViewController:(UISplitViewController *)splitController willShowViewController:(UIViewController *)viewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem 110{ 111 [self.navigationItem setLeftBarButtonItem:nil animated:YES]; 112 self.masterPopoverController = nil; 113} 114 115@end 116