Skip to content

Commit 0e07937

Browse files
author
sunhongwei
committed
update demo
1 parent 5466cb6 commit 0e07937

File tree

6 files changed

+46
-18
lines changed

6 files changed

+46
-18
lines changed

Example/my_flutter/.metadata

Lines changed: 0 additions & 10 deletions
This file was deleted.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>IDEDidComputeMac32BitWarning</key>
6+
<true/>
7+
</dict>
8+
</plist>

Example/my_native/my_native/AppDelegate.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111

1212
@interface AppDelegate : FlutterAppDelegate
1313

14-
@property (strong, nonatomic) UIWindow *window;
15-
14+
@property (nonatomic,strong) FlutterEngine *flutterEngine;
1615

1716
@end
1817

Example/my_native/my_native/AppDelegate.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ @implementation AppDelegate
1717

1818

1919
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
20-
[GeneratedPluginRegistrant registerWithRegistry:self];
20+
self.flutterEngine = [[FlutterEngine alloc] initWithName:@"io.flutter" project:nil];
21+
[self.flutterEngine runWithEntrypoint:nil];
22+
[GeneratedPluginRegistrant registerWithRegistry:self.flutterEngine];
2123
return [super application:application didFinishLaunchingWithOptions:launchOptions];
2224
}
2325

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,46 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" systemVersion="17A277" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="BYZ-38-t0r">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="dL7-cT-9Hb">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
7+
<deployment identifier="iOS"/>
8+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
59
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
610
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
711
</dependencies>
812
<scenes>
13+
<!--Navigation Controller-->
14+
<scene sceneID="9uT-ZM-ifr">
15+
<objects>
16+
<navigationController id="dL7-cT-9Hb" sceneMemberID="viewController">
17+
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="s1g-Vh-o5i">
18+
<rect key="frame" x="0.0" y="20" width="375" height="44"/>
19+
<autoresizingMask key="autoresizingMask"/>
20+
</navigationBar>
21+
<connections>
22+
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="jiV-mV-WtA"/>
23+
</connections>
24+
</navigationController>
25+
<placeholder placeholderIdentifier="IBFirstResponder" id="fE5-78-Ddh" userLabel="First Responder" sceneMemberID="firstResponder"/>
26+
</objects>
27+
<point key="canvasLocation" x="-716" y="-419"/>
28+
</scene>
929
<!--View Controller-->
1030
<scene sceneID="tne-QT-ifu">
1131
<objects>
12-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModuleProvider="" sceneMemberID="viewController">
32+
<viewController id="BYZ-38-t0r" customClass="ViewController" sceneMemberID="viewController">
1333
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
1434
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1535
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1636
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
1737
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
1838
</view>
39+
<navigationItem key="navigationItem" id="byq-pg-wZO"/>
1940
</viewController>
2041
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
2142
</objects>
43+
<point key="canvasLocation" x="47" y="-420"/>
2244
</scene>
2345
</scenes>
2446
</document>

Example/my_native/my_native/ViewController.m

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
//
88

99
#import "ViewController.h"
10+
#import "AppDelegate.h"
1011
#import <Flutter/Flutter.h>
1112

1213
@interface ViewController ()
@@ -27,9 +28,15 @@ - (void)viewDidLoad {
2728
[self.view addSubview:button];
2829
}
2930

31+
- (void)viewWillAppear:(BOOL)animated {
32+
[super viewWillAppear:animated];
33+
[self.navigationController setNavigationBarHidden:YES animated:animated];
34+
}
35+
3036
- (void)handleButtonAction {
31-
FlutterViewController* flutterViewController = [[FlutterViewController alloc] init];
32-
[self presentViewController:flutterViewController animated:false completion:nil];
37+
FlutterEngine *flutterEngine = [(AppDelegate *)[[UIApplication sharedApplication] delegate] flutterEngine];
38+
FlutterViewController *flutterViewController = [[FlutterViewController alloc] initWithEngine:flutterEngine nibName:nil bundle:nil];
39+
[self.navigationController pushViewController:flutterViewController animated:YES];
3340
}
3441

3542

0 commit comments

Comments
 (0)