Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
M-I-N opened this issue Jan 28, 2018 · 6 comments
Closed

Comments

@M-I-N
Copy link

M-I-N commented Jan 28, 2018

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)
}
@ephread
Copy link
Owner

ephread commented Jan 29, 2018

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.

@M-I-N
Copy link
Author

M-I-N commented Jan 29, 2018

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?

@M-I-N
Copy link
Author

M-I-N commented Jan 29, 2018

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.

@tectonicpie
Copy link

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

@tectonicpie
Copy link

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.

@ephread
Copy link
Owner

ephread commented Mar 24, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants