29
29
*
30
30
* ***********************************************************************/
31
31
32
- #include " ofxiOSAppDelegate.h"
32
+ #import " ofxiOSAppDelegate.h"
33
33
34
34
#if TARGET_OS_IOS || (TARGET_OS_IPHONE && !TARGET_OS_TV)
35
35
36
- #include " ofxiOSViewController.h"
37
- #include " ofxiOSExternalDisplay.h"
36
+ #import " ofxiOSViewController.h"
37
+ #import " ofxiOSGLKViewController.h"
38
+ #import " ofxiOSExternalDisplay.h"
38
39
#include " ofxiOSExtras.h"
39
40
#include " ofxiOSAlerts.h"
40
41
#include " ofxiOSEAGLView.h"
45
46
46
47
@implementation ofxiOSAppDelegate
47
48
48
- @synthesize window;
49
- @synthesize externalWindow;
50
49
@synthesize currentScreenIndex;
51
50
52
- @synthesize uiViewController;
53
-
54
51
- (void )dealloc {
55
52
self.window = nil ;
56
53
self.externalWindow = nil ;
57
54
self.uiViewController = nil ;
58
- [super dealloc ];
59
55
}
60
56
61
57
- (void )applicationDidFinishLaunching : (UIApplication *)application {
62
58
63
- self.window = [[[ UIWindow alloc ] initWithFrame: [[UIScreen mainScreen ] bounds ]] autorelease ];
59
+ self.window = [[UIWindow alloc ] initWithFrame: [[UIScreen mainScreen ] bounds ]];
64
60
[self .window makeKeyAndVisible ];
65
61
66
62
currentScreenIndex = 0 ;
@@ -145,11 +141,11 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
145
141
case METAL_KIT:
146
142
NSLog (@" No MetalKit yet supported for openFrameworks: Falling back to GLKit" );
147
143
case GL_KIT:
148
- self.uiViewController = (UIViewController*)[[[ ofxiOSGLKViewController alloc ] initWithFrame: frame app: (ofxiOSApp *)ofGetAppPtr () sharegroup: nil ] autorelease ];
144
+ self.uiViewController = (UIViewController *)[[ofxiOSGLKViewController alloc ] initWithFrame: frame app: (ofxiOSApp *)ofGetAppPtr () sharegroup: nil ];
149
145
break ;
150
146
case CORE_ANIMATION:
151
147
default :
152
- self.uiViewController = [[[ ofxiOSViewController alloc ] initWithFrame: frame app: (ofxiOSApp *)ofGetAppPtr () sharegroup: nil ] autorelease ];
148
+ self.uiViewController = [[ofxiOSViewController alloc ] initWithFrame: frame app: (ofxiOSApp *)ofGetAppPtr () sharegroup: nil ];
153
149
break ;
154
150
155
151
}
@@ -172,14 +168,22 @@ - (void)applicationDidFinishLaunching:(UIApplication *)application {
172
168
}
173
169
174
170
if (!bDoesHWOrientation) {
175
- if ([self .uiViewController respondsToSelector: @selector (rotateToInterfaceOrientation:animated: )]) {
176
- [self .uiViewController rotateToInterfaceOrientation: UIInterfaceOrientationPortrait animated: false ];
177
- }
171
+ if ([self .uiViewController isKindOfClass: ofxiOSViewController.class ]) {
172
+ ofxiOSViewController *controller = (ofxiOSViewController*)self.uiViewController ;
173
+ [controller rotateToInterfaceOrientation: UIInterfaceOrientationPortrait animated: false ];
174
+ } else if ([self .uiViewController isKindOfClass: ofxiOSGLKViewController.class ]) {
175
+ ofxiOSGLKViewController *controller = (ofxiOSGLKViewController *)self.uiViewController ;
176
+ [controller rotateToInterfaceOrientation: UIInterfaceOrientationPortrait animated: false ];
177
+ }
178
178
} else {
179
179
[[UIApplication sharedApplication ] setStatusBarOrientation: interfaceOrientation animated: NO ];
180
- if ([self .uiViewController respondsToSelector: @selector (rotateToInterfaceOrientation:animated: )]) {
181
- [self .uiViewController rotateToInterfaceOrientation: interfaceOrientation animated: false ];
182
- }
180
+ if ([self .uiViewController isKindOfClass: ofxiOSViewController.class ]) {
181
+ ofxiOSViewController *controller = (ofxiOSViewController*)self.uiViewController ;
182
+ [controller rotateToInterfaceOrientation: UIInterfaceOrientationPortrait animated: false ];
183
+ } else if ([self .uiViewController isKindOfClass: ofxiOSGLKViewController.class ]) {
184
+ ofxiOSGLKViewController *controller = (ofxiOSGLKViewController *)self.uiViewController ;
185
+ [controller rotateToInterfaceOrientation: UIInterfaceOrientationPortrait animated: false ];
186
+ }
183
187
ofSetOrientation (requested);
184
188
}
185
189
@@ -239,11 +243,17 @@ - (void)receivedRotate:(NSNotification*)notification {
239
243
if ( [[[UIDevice currentDevice ] systemVersion ] compare: @" 8.0" options: NSNumericSearch] == NSOrderedAscending ) {
240
244
// iOS7-
241
245
if (deviceOrientation != UIDeviceOrientationUnknown && deviceOrientation != UIDeviceOrientationFaceUp && deviceOrientation != UIDeviceOrientationFaceDown ) {
242
- if ([self .uiViewController respondsToSelector: @selector (isReadyToRotate )]) {
243
- if ([self .uiViewController isReadyToRotate ]) {
244
- ofxiOSAlerts.deviceOrientationChanged ( deviceOrientation );
245
- }
246
- }
246
+ if ([self .uiViewController isKindOfClass: ofxiOSViewController.class ]) {
247
+ ofxiOSViewController *controller = (ofxiOSViewController*)self.uiViewController ;
248
+ if ([controller isReadyToRotate ]) {
249
+ ofxiOSAlerts.deviceOrientationChanged ( deviceOrientation );
250
+ }
251
+ } else if ([self .uiViewController isKindOfClass: ofxiOSGLKViewController.class ]) {
252
+ ofxiOSGLKViewController *controller = (ofxiOSGLKViewController *)self.uiViewController ;
253
+ if ([controller isReadyToRotate ]) {
254
+ ofxiOSAlerts.deviceOrientationChanged ( deviceOrientation );
255
+ }
256
+ }
247
257
}
248
258
}else {
249
259
ofxiOSAlerts.deviceOrientationChanged ( deviceOrientation );
@@ -293,7 +303,7 @@ - (BOOL)createExternalWindowWithPreferredMode {
293
303
externalScreenFrame = CGRectZero ;
294
304
externalScreenFrame.size = CGSizeMake (w, h);
295
305
296
- self.externalWindow = [[[ UIWindow alloc ] initWithFrame: externalScreenFrame] autorelease ];
306
+ self.externalWindow = [[UIWindow alloc ] initWithFrame: externalScreenFrame];
297
307
self.externalWindow .screen = externalScreen;
298
308
self.externalWindow .clipsToBounds = YES ;
299
309
self.externalWindow .hidden = NO ;
@@ -331,7 +341,7 @@ - (BOOL)createExternalWindowWithScreenModeIndex:(NSInteger)screenModeIndex {
331
341
externalScreenFrame = CGRectZero ;
332
342
externalScreenFrame.size = CGSizeMake (w, h);
333
343
334
- self.externalWindow = [[[ UIWindow alloc ] initWithFrame: externalScreenFrame] autorelease ];
344
+ self.externalWindow = [[UIWindow alloc ] initWithFrame: externalScreenFrame];
335
345
self.externalWindow .screen = externalScreen;
336
346
self.externalWindow .clipsToBounds = YES ;
337
347
self.externalWindow .hidden = NO ;
0 commit comments