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、结果

相关推荐
HarderCoder1 天前
Swift 6 并发时代,如何优雅地“抢救”你的单例?
swift
zhangmeng1 天前
FlutterBoost在iOS26真机运行崩溃问题
flutter·app·swift
HarderCoder1 天前
SwiftUI 踩坑记:onAppear / task 不回调?90% 撞上了“空壳视图”!
swift
HarderCoder1 天前
@isolated(any) 深度解析:Swift 并发中的“隔离追踪器”
swift
大熊猫侯佩1 天前
桃花岛 Xcode 构建秘籍:Swift 中的 “Feature Flags” 心法
app·xcode·swift
用户091 天前
SwiftUI Charts 函数绘图完全指南
ios·swiftui·swift
YungFan1 天前
iOS26适配指南之UIColor
ios·swift
HarderCoder1 天前
Swift 6.2 新特性 `@concurrent` 完全导读
swift
HarderCoder1 天前
Swift 里的“橡皮擦”与“标签”——搞懂 existentials 与 primary associated type
swift
权咚2 天前
阿权的开发经验小集
git·ios·xcode