diff options
| author | assiduous <assiduous@diligentgraphics.com> | 2020-02-20 19:24:50 +0000 |
|---|---|---|
| committer | assiduous <assiduous@diligentgraphics.com> | 2020-02-20 19:24:50 +0000 |
| commit | 89fea8d1796c2a9269bae00d3f0a5a9b55f77cd0 (patch) | |
| tree | a2e3c57ec8fdd567ca405ce7e08e3a327399b1b9 /NativeApp | |
| parent | travis.yml: switched to using xcode 11.1 (diff) | |
| download | DiligentTools-89fea8d1796c2a9269bae00d3f0a5a9b55f77cd0.tar.gz DiligentTools-89fea8d1796c2a9269bae00d3f0a5a9b55f77cd0.zip | |
Fixed deprecation warnings on iOS
Diffstat (limited to 'NativeApp')
| -rw-r--r-- | NativeApp/Apple/Source/Classes/iOS/AppViewBase.h | 2 | ||||
| -rw-r--r-- | NativeApp/Apple/Source/Classes/iOS/AppViewBase.m | 30 | ||||
| -rw-r--r-- | NativeApp/Apple/Source/Classes/iOS/ModeSelectionViewController.mm | 21 |
3 files changed, 29 insertions, 24 deletions
diff --git a/NativeApp/Apple/Source/Classes/iOS/AppViewBase.h b/NativeApp/Apple/Source/Classes/iOS/AppViewBase.h index e6273e9..c6d5143 100644 --- a/NativeApp/Apple/Source/Classes/iOS/AppViewBase.h +++ b/NativeApp/Apple/Source/Classes/iOS/AppViewBase.h @@ -4,7 +4,7 @@ @interface AppViewBase : BaseView -@property (nonatomic) NSInteger animationFrameInterval; +@property (nonatomic) NSInteger preferredFramesPerSecond; - (void) initApp:(int)deviceType; - (void) startAnimation; diff --git a/NativeApp/Apple/Source/Classes/iOS/AppViewBase.m b/NativeApp/Apple/Source/Classes/iOS/AppViewBase.m index 8bc50e2..84d1b01 100644 --- a/NativeApp/Apple/Source/Classes/iOS/AppViewBase.m +++ b/NativeApp/Apple/Source/Classes/iOS/AppViewBase.m @@ -8,7 +8,7 @@ @interface AppViewBase () { std::unique_ptr<Diligent::NativeAppBase> _theApp; - NSInteger _animationFrameInterval; + NSInteger _preferredFramesPerSecond; CADisplayLink* _displayLink; std::string _error; } @@ -29,9 +29,9 @@ _error = err.what(); _theApp.reset(); } - + [super stopAnimation]; - _animationFrameInterval = 1; + _preferredFramesPerSecond = 60; _displayLink = nil; } @@ -49,30 +49,24 @@ { auto bounds = [self.layer bounds]; auto scale = [self.layer contentsScale]; - + if(_theApp) { _theApp->WindowResize(bounds.size.width * scale, bounds.size.height * scale); } } -- (NSInteger) animationFrameInterval +- (NSInteger) preferredFramesPerSecond { - return _animationFrameInterval; + return _preferredFramesPerSecond; } -- (void) setAnimationFrameInterval:(NSInteger)frameInterval +- (void) setPreferredFramesPerSecond:(NSInteger)preferredFPS { - // Frame interval defines how many display frames must pass between each time the - // display link fires. The display link will only fire 30 times a second when the - // frame internal is two on a display that refreshes 60 times a second. The default - // frame interval setting of one will fire 60 times a second when the display refreshes - // at 60 times a second. A frame interval setting of less than one results in undefined - // behavior. - if (frameInterval >= 1) + if (preferredFPS >= 1) { - _animationFrameInterval = frameInterval; - + _preferredFramesPerSecond = preferredFPS; + if (self.animating) { [self stopAnimation]; @@ -89,11 +83,11 @@ _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(drawView:)]; // Set it to our _animationFrameInterval - [_displayLink setFrameInterval:_animationFrameInterval]; + [_displayLink setPreferredFramesPerSecond:_preferredFramesPerSecond]; // Have the display link run on the default runn loop (and the main thread) [_displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; - + [super startAnimation]; } } diff --git a/NativeApp/Apple/Source/Classes/iOS/ModeSelectionViewController.mm b/NativeApp/Apple/Source/Classes/iOS/ModeSelectionViewController.mm index 8958c10..0311121 100644 --- a/NativeApp/Apple/Source/Classes/iOS/ModeSelectionViewController.mm +++ b/NativeApp/Apple/Source/Classes/iOS/ModeSelectionViewController.mm @@ -32,17 +32,28 @@ -(void)selectViewController:(NSString*)controllerID { auto animating = ((BaseView*)self.view).animating; - + UIViewController* viewController = [self.storyboard instantiateViewControllerWithIdentifier:controllerID]; self.view.window.rootViewController = viewController; - + NSString *error = [(AppViewBase*)viewController.view getError]; if(error != nil) { - UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failed to start the application" message:error delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"Whatever", nil]; - [alert show]; + UIAlertController* alert = [UIAlertController + alertControllerWithTitle:@"Failed to start the application" + message:error + preferredStyle:UIAlertControllerStyleAlert]; + + UIAlertAction* okButton = [UIAlertAction + actionWithTitle:@"OK" + style:UIAlertActionStyleDefault + handler:nil]; + + [alert addAction:okButton]; + + [viewController presentViewController:alert animated:YES completion:nil]; } - + if(animating) { [(BaseView*)viewController.view startAnimation]; |
