Skip to content

Commit 2312a71

Browse files
committed
Fix AxmolViewController lifecycle methods are not invoked on iOS (#3026)
1 parent 4b20733 commit 2312a71

5 files changed

Lines changed: 16 additions & 9 deletions

File tree

core/axmolver.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// 00 03 08 00
66
#define AX_VERSION_MAJOR 2
77
#define AX_VERSION_MINOR 11
8-
#define AX_VERSION_PATCH 1
8+
#define AX_VERSION_PATCH 2
99

1010
/* Define axmol version helper macros */
1111
#define AX_VERSION_MAKE(a, b, c) ((a << 16) | (b << 8) | (c & 0xff))

core/platform/ios/AxmolViewController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,6 @@
2929
}
3030
- (BOOL)prefersStatusBarHidden;
3131

32+
@property(nonatomic, readwrite) UIView* hostView;
33+
3234
@end

core/platform/ios/AxmolViewController.mm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ of this software and associated documentation files (the "Software"), to deal
2424

2525
#import "AxmolViewController.h"
2626
#import "platform/ios/RenderHostView-ios.h"
27+
#import "platform/ios/RenderViewImpl-ios.h"
2728
#include "platform/Device.h"
2829
#include "platform/Application.h"
2930
#include "base/Director.h"
@@ -44,9 +45,10 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
4445
*/
4546

4647
// Implement loadView to create a view hierarchy programmatically, without using a nib.
47-
// - (void)loadView
48-
// {
49-
// }
48+
- (void)loadView
49+
{
50+
self.view = self.hostView;
51+
}
5052

5153
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
5254
- (void)viewDidLoad

core/platform/ios/RenderViewImpl-ios.mm

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ of this software and associated documentation files (the "Software"), to deal
2929
#include "platform/ios/RenderHostView-ios.h"
3030
#include "platform/ios/DirectorCaller-ios.h"
3131
#include "platform/ios/RenderViewImpl-ios.h"
32+
#include "platform/ios/AxmolViewController.h"
3233
#include "platform/Device.h"
3334
#include "base/Touch.h"
3435
#include "base/Director.h"
@@ -147,8 +148,6 @@ static CGSize computeLogicalScreenSize()
147148

148149
RenderViewImpl::~RenderViewImpl()
149150
{
150-
// auto eaView = (__bridge RenderHostView*) _hostViewHandle;
151-
//[eaView release];
152151
}
153152

154153
#ifndef AX_CORE_PROFILE
@@ -224,13 +223,13 @@ static CGSize computeLogicalScreenSize()
224223
void RenderViewImpl::showWindow(void* viewController)
225224
{
226225
auto window = (__bridge UIWindow*)_hostWindowHandle;
227-
auto controller = (__bridge UIViewController*)viewController;
226+
auto controller = (__bridge AxmolViewController*)viewController;
228227

229228
#if !defined(AX_TARGET_OS_TVOS)
230229
controller.extendedLayoutIncludesOpaqueBars = YES;
231230
#endif
232-
auto view = (__bridge RenderHostView*)_hostViewHandle;
233-
controller.view = view;
231+
232+
controller.hostView = (__bridge UIView*)_hostViewHandle;
234233

235234
// Set RootViewController to window
236235
if ([[UIDevice currentDevice].systemVersion floatValue] < 6.0)

templates/common/proj.ios_mac/ios/GameViewController.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,9 @@ of this software and associated documentation files (the "Software"), to deal
3030
@implementation GameViewController
3131

3232
// Override to allow custom control the app behavior.
33+
- (void)viewDidLoad
34+
{
35+
[super viewDidLoad];
36+
}
3337

3438
@end

0 commit comments

Comments
 (0)