From 2bbc0283138042380eae1aca64236231d9b407dd Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Thu, 2 Feb 2017 12:50:01 -0800 Subject: [PATCH] Add touchesBegan handler to iOS AppDelegate template (#7822) By default, pass status bar taps to the root view controller in generated Flutter apps. Developers should customise as necesary if they later create one or more alternate FlutterViewControllers that they'd like to forward these to. --- .../templates/create/ios.tmpl/Runner/AppDelegate.m | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/packages/flutter_tools/templates/create/ios.tmpl/Runner/AppDelegate.m b/packages/flutter_tools/templates/create/ios.tmpl/Runner/AppDelegate.m index d4cfa3ad4b5..8b9b8595a3c 100644 --- a/packages/flutter_tools/templates/create/ios.tmpl/Runner/AppDelegate.m +++ b/packages/flutter_tools/templates/create/ios.tmpl/Runner/AppDelegate.m @@ -30,4 +30,16 @@ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } +- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { + [super touchesBegan:touches withEvent:event]; + + // Support scroll to top on status bar tap. By default, pass status bar taps + // to the application's root view controller for handling in Flutter. + UIViewController *viewController = + [UIApplication sharedApplication].keyWindow.rootViewController; + if ([viewController isKindOfClass:[FlutterViewController class]]) { + [(FlutterViewController*)viewController handleStatusBarTouches:event]; + } +} + @end