Flutter开发之——IOSView,安卓开发自学教程

这篇博客介绍了如何在Flutter应用中嵌入iOS自定义View,并实现两端的参数传递和通信。通过在AppDelegate中注册、编辑Flutter页面,创建MethodChannel,实现了Flutter向iOS View发送消息并接收参数的功能。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

import Foundation

import Flutter

class MyFlutterViewFactory: NSObject,FlutterPlatformViewFactory {

var messenger:FlutterBinaryMessenger

init(messenger:FlutterBinaryMessenger) {

self.messenger = messenger

super.init()

}

func create(withFrame frame: CGRect, viewIdentifier viewId: Int64, arguments args: Any?) -> FlutterPlatformView {

return MyFlutterView(frame,viewID: viewId,args: args,messenger: messenger)

}

func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {

return FlutterStandardMessageCodec.sharedInstance()

}

}

3.4 在 AppDelegate 中注册

import UIKit

import Flutter

@UIApplicationMain

@objc class AppDelegate: FlutterAppDelegate {

override func application(

_ application: UIApplication,

didFinishLaunchingW

《Android学习笔记总结+最新移动架构视频+大厂安卓面试真题+项目实战源码讲义》

开源分享完整内容戳这里

ithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?

) -> Bool {

GeneratedPluginRegistrant.register(with:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值