ViewController.m

#import "ViewController.h"
#import <Flutter/Flutter.h>
#include "GeneratedPluginRegistrant.h"
#import "SettingViewController.h"

@interface ViewController ()
{
FlutterViewController *flutterVC;
FlutterMethodChannel *batteryChannel;
}
@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.title = @"我是iOS 页面";

flutterVC = [[FlutterViewController alloc]initWithProject:nil nibName:nil bundle:nil];
flutterVC.title = @"我是Flutter页面";
batteryChannel = [FlutterMethodChannel methodChannelWithName:@"samples.flutter.dev/battery" binaryMessenger:flutterVC];
}

- (IBAction)pushNext:(id)sender {
NSLog(@"你好吗?");

//如果使用了插件显示view
[GeneratedPluginRegistrant registerWithRegistry:flutterVC];
//[flutterVC setInitialRoute:@"myApp12"];
[flutterVC setInitialRoute:@"myApp"];
[self.navigationController pushViewController:flutterVC animated:YES];

__weak typeof(self) weakSelf = self;
[batteryChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
// Note: this method is invoked on the UI thread.
if ([@"getBatteryLevel" isEqualToString:call.method])
{
int batteryLevel = [weakSelf getBatteryLevel];
if (batteryLevel == -1) {
result([FlutterError errorWithCode:@"UNAVAILABLE" message:@"Battery info unavailable" details:nil]);
} else {(http://www.amjmh.com)
result(@(batteryLevel));
}

} else if ([@"backToNavigatorIndex" isEqualToString:call.method]) {
NSArray *arguments = call.arguments;

NSNumber *inde = arguments[0];
NSLog(@"arguments :%@",inde);
int batteryLevel = [weakSelf backToNavigatorIndex:inde];
result(@(batteryLevel));
} else {
result(FlutterMethodNotImplemented);
}
}];
}

- (IBAction)passArgusToFlutter:(id)sender {

NSLog(@"passArgusToFlutter");
[batteryChannel invokeMethod:@"passArgusToFlutter" arguments:@[@12,@"huahua"] result:^(id _Nullable result) {
NSString *ggg = (NSString *)result;
NSLog(@"result----:%@",ggg);
}];
}

- (int)getBatteryLevel {
NSLog(@"nihao!!!!!");
SettingViewController *settingVC = [[SettingViewController alloc]init];
[flutterVC.navigationController pushViewController:settingVC animated:YES];

return 66;
}

- (int)backToNavigatorIndex:(NSNumber*)index {
NSLog(@"backToNavigatorIndex!!!!!");
UIViewController *VC = flutterVC.navigationController.viewControllers[0];
[flutterVC.navigationController popToViewController:VC animated:YES];

return 33;
}

---------------------

最新文章

  1. 虚拟机安装windows服务出现无法打开内核设备“\\.Global\vmx86”
  2. When building php 5.3, if you get the following error:
  3. Visual Studio 发布新版API智能提示
  4. 跨代的对决 英特尔i7-6700HQ对比i7-4720HQ性能测试
  5. NOIP总结
  6. JavaScript Garden
  7. android图片闪烁或帧动画
  8. insert into select * from 锁表
  9. Delphi Excel
  10. Java多线程同步方法Synchronized和volatile
  11. POJ 2406 Power Strings(字符串的最小循环节)
  12. Jmeter正则提取list中相同key的value和出现的次数
  13. 606. Construct String from Binary Tree
  14. Kali Linux 渗透测试手册(1.1)安装虚拟机
  15. 从0开始的Python学习005运算符与表达式
  16. Linux-学习patch命令打补丁,diff命令制作补丁(3)
  17. python之模块使用
  18. Java数组超出范围时如何处理多个异常?
  19. 这可能是最简明扼要的 js事件冒泡机制+阻止默认事件 讲解了
  20. 【BZOJ2946】[Poi2000]公共串 后缀数组+二分

热门文章

  1. linux 简单安装mongodb
  2. [19/05/16-星期四] HTML_body标签(表格标签)
  3. Super Mario HDU 4417 主席树区间查询
  4. go中string类型转换为基本数据类型的方法
  5. append动态生成的元素,无法触发事件的原因及解决方案
  6. 基于Xilinx Kintex-7 FPGA K7 XC7K325T PCIeX8 四路光纤卡
  7. git的HEAD指针操作
  8. poj 1269 Intersecting Lines(直线相交)
  9. 客户端模拟线程线程池发送100个文件给socket
  10. Android Studio使用阿里云Aliyun Maven仓库