mirror of
https://github.com/flutter/flutter.git
synced 2026-02-20 02:29:02 +08:00
Use FlutterAppDelegate in iOS create template (#7845)
On iOS, generate a FlutterAppDelegate subclass for the application delegate. This avoids touchesBegan:withEvent boilerplate to handle status bar taps.
This commit is contained in:
parent
484067edd7
commit
aaff608d05
@ -1,7 +1,6 @@
|
||||
#import <UIKit/UIKit.h>
|
||||
#import <Flutter/Flutter.h>
|
||||
|
||||
@interface AppDelegate : UIResponder <UIApplicationDelegate>
|
||||
|
||||
@property (strong, nonatomic) UIWindow *window;
|
||||
@interface AppDelegate : FlutterAppDelegate
|
||||
|
||||
@end
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
#import <Flutter/Flutter.h>
|
||||
#include "AppDelegate.h"
|
||||
|
||||
@implementation AppDelegate
|
||||
@ -30,16 +29,4 @@
|
||||
// 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user