SwiftKickMobile / SwiftMessages

A very flexible message bar for UIKit and SwiftUI.
MIT License
7.35k stars 748 forks source link

Can't disable "tap to hide" for MessageView #214

Closed muzoman closed 6 years ago

muzoman commented 6 years ago

Hi there,

I've got a MessageView configured as a .statusLine and I want to stop user taps from hiding the message. I can't seem to do this.

I've tried setting the .tapHandler property to { view in } i.e. do nothing, but this doesn't work.

I've tried setting the configuration property .interactiveHide to false too and this also has no effect.

What am I doing wrong? I assume this is possible?

Thanks!

wtmoose commented 6 years ago

Hi. There are only four ways a message view can get dismissed:

  1. Setting interactiveHide = true enables the pan dismiss gesture
  2. Setting dimMode = .gray(interactive: true) (or a similar case) dismisses the message when you tap outside of the message
  3. Setting .duration to anything other than .automatic or seconds(seconds:) dismisses the message after a period of time.
  4. You call hide()

I suggest that you put a breakpoint in SwiftMessages.hideCurrent() and look at the stack trace to figure out which of the above is happening.

The .tapHandler property does nothing by default.

muzoman commented 6 years ago

Ok, thanks Tim, my issue wasn't quite what I thought it was!

The message view was being removed by a navigation drawer component that hid the status bar area as a view controller was animated in from the left side of the screen. Strangely, even though the component restored the statusbar area afterwards the message view would never be displayable again.

For reference, if anyone else comes up against this problem it was in a UI library called Material by CosmicMind and the class was AppNavigationDrawerController - https://github.com/CosmicMind/Material

The component has a property called isHiddenStatusBarEnabled which if set to false stops the status bar being hidden and the problem is solved.

wtmoose commented 6 years ago

Good to hear you figured it out.

moizirshad commented 4 years ago

Works for me.

config.dimMode = .gray(interactive: false)