IOS-ViewController与Storyboard进行绑定-Swift

在IOS中,新建项目时默认有一个Main.storyboard和ViewController,这两个是默认绑定的。

但是如果自己新建了ViewCOntroller与storyboard文件,想将两者绑定起来,那就可以这样:

1、选中storyboard文件,将其class设置为自己新建的ViewController,并设置Storyboard ID

2、实现页面跳转

在某个点击事件中实现页面跳转

swift 复制代码
		let test=UIStoryboard(name: "Test", bundle: nil)
        let test_vc=test.instantiateViewController(identifier: "test")
        self.present(test_vc, animated: true)

3、做绑定测试

在Storyboard中拉出一个按钮,并设置引用,拿到引用修改按钮标题

4、结果

相关推荐
Swift社区16 小时前
LeetCode 401 二进制手表 - Swift 题解
算法·leetcode·swift
humors22117 小时前
[原创]AI工具:读取手机系统文件工具
windows·ios·安卓·鸿蒙·文件·苹果·读取
humors22118 小时前
[原创]AI工具:手机文件查杀病毒工具
windows·ios·手机·安卓·鸿蒙·杀毒·苹果
2501_915918411 天前
iOS性能测试工具 Instruments、Keymob的使用方法 不局限 FPS
android·ios·小程序·https·uni-app·iphone·webview
左左右右左右摇晃1 天前
Tasker笔记
ios·iphone
恋猫de小郭2 天前
Android Studio Panda 3 发布,CMP 导致的 Gemini 输入问题
android·ide·flutter·ios·android studio
2501_915918412 天前
iOS 混淆流程 提升 IPA 分析难度 实现 IPA 深度加固
android·ios·小程序·https·uni-app·iphone·webview
Batac_蝠猫2 天前
值类型与引用类型:struct 与 class 的分工
swift
Digitally2 天前
如何将文件从 Mac / 苹果笔记本传输至 iPad
macos·ios·ipad
2501_915909062 天前
React Native 上架 App Store:项目运行与审核构建的流程
android·ios·小程序·https·uni-app·iphone·webview