iT邦幫忙

2025 iThome 鐵人賽

DAY 28
0
Mobile Development

Xcode x Swift Vibe coding進階開發之旅系列 第 28

Xcode x Swift Vibe coding進階開發之旅 第二十八天 客製化tarbar(5) 不如意的AI

  • 分享至 

  • xImage
  •  

說明

原本想直接用AI但發現結果錯誤百出且點作用都沒有,所以再加上一些設定。/images/emoticon/emoticon08.gif

程式

增加protocol及部分宣告
Btn:

    var delegate:  btnViewDelegate?
 var delegate:  btnViewDelegate?
    var stringTag: Int?
    
    var buttonTapped: ((Int) -> ())? = nil
    
protocol btnViewDelegate : AnyObject {
    func didTapButton(tag: Int)
}

tarbar:

 var buttonTappen: ((Int) -> ())? = nil
    let item = BottomItems.allCases
    
extension tarbarViewController: btnViewDelegate {
    func didTapButton(tag: Int) {
        buttonTappen?(item[tag].rawValue)
        print("Button tapped with tag: \(tag)")
    }
}

Main:

 private var onev = oneViewController()
        private var twov = twoViewController()
        private var threev = threeViewController()
        var vc: [UIViewController] = []
        var nowVC: Int = BottomItems.oneViewController.rawValue
    

上一篇
Xcode x Swift Vibe coding進階開發之旅 第二十七天 客製化tarbar(4) 定義切換畫面
下一篇
Xcode x Swift Vibe coding進階開發之旅 第二十九天 客製化tarbar(6) 不如意的AI
系列文
Xcode x Swift Vibe coding進階開發之旅29
圖片
  熱門推薦
圖片
{{ item.channelVendor }} | {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言