Skip to content

CoachMark is getting out of the screen bounds when applied to table view #152

Closed

Description

@M-I-N

I've made coach marks for several components of my view controller (e.g. navigationBar, rightBarButtonItem, tableView, a custom UIButton). Other coach marks but the one for tableView are being shown appropriately inside the screen bounds. What's wrong when using it with tableView?

Screenshots:
screen shot 2018-01-28 at 8 00 13 pm

screen shot 2018-01-28 at 8 00 20 pm

I've followed your default style implementation.

Here are some code snippets:

func coachMarksController(_ coachMarksController: CoachMarksController, coachMarkAt index: Int) -> CoachMark {
    switch index {
    case 0:
        ....
        ....
    case 2:
        return coachMarksController.helper.makeCoachMark(for: self.tableView)
        ....
        ....
    }
}
func coachMarksController(_ coachMarksController: CoachMarksController, coachMarkViewsAt index: Int, madeFrom coachMark: CoachMark) -> (bodyView: CoachMarkBodyView, arrowView: CoachMarkArrowView?) {
    let coachViews = coachMarksController.helper.makeDefaultCoachViews(withArrow: true, arrowOrientation: coachMark.arrowOrientation)
    switch index {
    case 0:
        ....
        ....
    case 2:
        coachViews.bodyView.hintLabel.text = self.tableViewInstructionText
        coachViews.bodyView.nextLabel.text = self.okInstructionText
        ....
        ....
    }
    return (bodyView: coachViews.bodyView, arrowView: coachViews.arrowView)
}

Activity

  1. ephread commented on Jan 29, 2018

    @ephread
    Owner

    Hello @M-I-N, the reason you're seeing this awkward behavior is because your tableview spans more than half the screen. (Meaning that the engine get confused as to where to put the coach mark and resort to the default position.)

    It'll certainly be an improvement to check the space remaining and place the coachmark where there's the most of it.

    In the meantime, since you've got more space on the top, you can try to force the orientation in coachMarksController(_:, coachMarkAt:) or coachMarksController(_:, coachMark:, at:) see here.

  2. M-I-N commented on Jan 29, 2018

    @M-I-N
    Author

    Hi @ephread , thanks for the quick reply from you.

    I've tried the approach you suggested (force the orientation so that CoachMark is shown above the table view). But this isn't changing anything. The CoachMark is still on the bottom.

    But it seems I could do it with

    coachMark.arrowOrientation = .bottom

    My TableView is top aligned with the Safe Area and I'm using Navigation Bar(long style with iOS 11 but traditional with less targets) with Navigation Controller. So basically it'll work on iOS 11+ but not with < iOS 11.

    Any idea how to deal with < iOS 11?

  3. M-I-N commented on Jan 29, 2018

    @M-I-N
    Author

    Meanwhile, the documentation in the CoachMarkArrowOrientation enum should be changed to something like:

    /// An arrow can either sit at the bottom of the given view with CoachMark on bottom of it and point upward (.Top) or
    /// sit at the top of the given view with CoachMark on top of it and point downward. (.Bottom)

    to reflect the actual behavior.

  4. tectonicpie commented on Feb 26, 2018

    @tectonicpie

    I did it with coachMark.arrowOrientation = .bottom as well.

  5. tectonicpie commented on Feb 28, 2018

    @tectonicpie

    Hi @ephread it would be very helpful if it were possible to place the coachmark above view it is highlighting. For example for a tableview or for any other view, that covers a large area of the screen, the ability to place the coach mark over the view itself would save a lot of trouble.

  6. ephread commented on Mar 24, 2018

    @ephread
    Owner

    @tectonicpie That's a good idea, I'll put that on the roadmap.

  7. added a commit that references this issue on Nov 29, 2019
    25d6082
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions