Instructions icon indicating copy to clipboard operation
Instructions copied to clipboard

nextControl not working when we create custom view using xib.

Open parth-simformsolutions opened this issue 5 years ago • 5 comments

Describe the bug

I have created CoachMarkBodyView with xib. I have return unbutton as nextControl which I have connected using outlets. Now I am not able to click on next button.

To Reproduce

Expected behavior

Actually I should able to click on next button and it should show next instruction.

parth-simformsolutions avatar Feb 02 '21 07:02 parth-simformsolutions

Hi @parth-simformsolutions, thanks for reporting the problem. This is a very vague issue, do you have more information or a minimal project you can share?

How/where do you instantiate your XIB?

ephread avatar Feb 06 '21 21:02 ephread

Hi! I'm sorry I intervene, but I did too, Here's my code:

import UIKit
import Instructions

class ProfileCoachMarkView: UIView, CoachMarkBodyView {
    
    @IBOutlet private weak var labelMessage: UILabel!
    @IBOutlet weak var buttonOK: UIButton!
    
    var nextControl: UIControl? { return self.buttonOK }
    weak var highlightArrowDelegate: CoachMarkBodyHighlightArrowDelegate?
    
    static let popupWidth = UIScreen.main.bounds.width
    static func fromNib() -> ProfileCoachMarkView {
        return Bundle(for: ProfileCoachMarkView.self).loadNibNamed(String(describing: ProfileCoachMarkView.self), owner: nil, options: nil)![0] as! ProfileCoachMarkView
    }

static func viewPopup() -> ProfileCoachMarkView {
        let viewBody = ProfileCoachMarkView.fromNib()
        viewBody.buttonOK.accessibilityIdentifier = "AccessibilityIdentifiers.next"
        viewBody.frame = CGRect(x: 0, y: 0, width: ProfileCoachMarkView.popupWidth - 32, height: ProfileCoachMarkView.popupWidth * 0.35)
        viewBody.isUserInteractionEnabled = true
        viewBody.buttonOK.isUserInteractionEnabled = true
        return viewBody
    }
    
}

And i instantiate, like this:

extension ProfileViewController: CoachMarksControllerDataSource, CoachMarksControllerDelegate {
    func coachMarksController(
        _ coachMarksController: CoachMarksController,
        coachMarkViewsAt index: Int,
        madeFrom coachMark: CoachMark
    ) -> (
        bodyView: (UIView & CoachMarkBodyView),
        arrowView: (UIView & CoachMarkArrowView)?
    ) {
        
        let viewBody = ProfileCoachMarkView.viewPopup()
        return (bodyView: viewBody, arrowView: nil)
        
    }
    
    func coachMarksController(_ coachMarksController: CoachMarksController, coachMarkAt index: Int) -> CoachMark {
        return self.coachMark ?? coachMarksController.helper.makeCoachMark(for: tableView)
    }
    
    func numberOfCoachMarks(for coachMarksController: CoachMarksController) -> Int {
        return 1
    }
}

I followed the custom view example, but used xib, am i miss some configurations or something?

Thank you!

seirifat avatar May 18 '21 04:05 seirifat

Hey @seirifat, what problem do you see exactly with that code? Anything pops up in the console?

ephread avatar May 19 '21 17:05 ephread

Hi,

I'm having the same problem but only on iPad, when i tap on Next nothing happens, created custom target for the button but also nothing happens.

It's working fine on iPhone.

yasserosama07 avatar Sep 01 '21 14:09 yasserosama07

Hi, facing same issue. Please help me to overcome this 🥹.

Mukeshkumarmsd avatar Jul 13 '23 09:07 Mukeshkumarmsd