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

相关推荐
sweet丶5 分钟前
SDWebImage深度解析:高效图片加载背后的架构设计与卓越实践
ios·图片资源
Zender Han4 小时前
Flutter Gradients 全面指南:原理、类型与实战使用
android·flutter·ios
如此风景6 小时前
IOS开发SwiftUI相关学习记录
ios
2501_915909066 小时前
iOS 反编译防护工具全景解析 从底层符号到资源层的多维安全体系
android·安全·ios·小程序·uni-app·iphone·webview
linweidong6 小时前
网易ios面试题及参考答案(下)
objective-c·swift·ios开发·切面编程·ios面试·苹果开发·mac开发
Redundantº13 小时前
Uniapp 适配安卓与 iOS 的 PDF、DOC 文件上传
android·ios·pdf·uni-app·webview
大熊猫侯佩14 小时前
Swift 迭代三巨头(下集):Sequence、Collection 与 Iterator 深度狂飙
swift·编程语言·apple
大熊猫侯佩14 小时前
Swift 迭代三巨头(中集):Sequence、Collection 与 Iterator 深度狂飙
swift·编程语言·apple
大熊猫侯佩14 小时前
Swift 迭代三巨头(上集):Sequence、Collection 与 Iterator 深度狂飙
swift·编程语言·apple
lancoff14 小时前
#5 ScrollViewReader
ios·swiftui