【问题标题】:How to use instructions frame in our project如何在我们的项目中使用指令框架
【发布时间】:2021-09-08 11:10:18
【问题描述】:

我是 swift 的新手。我正在尝试在我的代码中使用Instructions framework。我已经成功地用这个函数实现了单个按钮“view_schedule”

@IBOutlet weak var view_schedule: UIButton!

@IBOutlet weak var use_now: UIButton!

func coachMarksController(_ coachMarksController: CoachMarksController, coachMarkAt index: Int) -> CoachMark {
    return coachMarksController.helper.makeCoachMark(for: view_schedule )
   

}

我如何为同一类中的多个按钮实现,即,ApplianceDetailVC.swift 用于我的下一个按钮“use_now”

我为此实现的逻辑是

var firstInstructionFlag = true
var secondInstructionFlag = false

func coachMarksController(_ coachMarksController: CoachMarksController, coachMarkAt index: Int) -> CoachMark {
    //var poi = UIView()
    if firstInstructionFlag == true
    {
        firstInstructionFlag = false
        secondInstructionFlag = true
        
        return coachMarksController.helper.makeCoachMark(for: view_schedule )
    }
    else if secondInstructionFlag == true
    {
        firstInstructionFlag = false
        secondInstructionFlag = false
        
        return coachMarksController.helper.makeCoachMark(for: use_now )
    }
    return coachMarksController.helper.makeCoachMark(for: use_now )
    
}

这个问题是我错误地处理了返回类型,为“use_now”重复它。你能通过提供更好的逻辑来处理这种返回类型吗

【问题讨论】:

    标签: ios swift iphone xcode


    【解决方案1】:
    func coachMarksController(_ coachMarksController: CoachMarksController, coachMarkAt index: Int) -> CoachMark {
        var poi=UIView()
        if firstInstructionFlag == true
        {
            firstInstructionFlag = false
            secondInstructionFlag = true
            poi = view_schedule
            
        }
        else if secondInstructionFlag == true
        {
            firstInstructionFlag = false
            secondInstructionFlag = false
            poi = use_now
        }
        return coachMarksController.helper.makeCoachMark(for:poi )
        
    }
    

    【讨论】:

    • 欢迎来到 Stack Overflow。请不要只提供一些代码,还要解释它是如何回答问题的。
    • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
    猜你喜欢
    • 1970-01-01
    • 2012-01-10
    • 1970-01-01
    • 2017-06-22
    • 1970-01-01
    • 2016-07-20
    • 2012-08-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多