-
Notifications
You must be signed in to change notification settings - Fork 190
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
contentView should be resized to fit within callout view #44
Comments
Hello (many months later, sorry!). So the callout is designed to size itself to fit the content view if defined. That's pretty ingrained into the structure of the callout. I'm sure you found a solution or workaround by now, but I'd be curious to hear why you'd want your content view to be resized for you? |
Sorry for the delayed response. The problem is that if the content is too wide to fit within the container view (as specified by constrainedToView in presentCalloutFromRect:...), then SMCalloutView resizes the callout to fit within the container view. When this happens, the content view needs to be resized as well. |
Interesting - so you're presenting a callout containing content that is too large to fit inside the constrainedToView without scrolling? |
Yes, our content may be quite wide. For example, in our Clue Tracker app we use SMCalloutView to show custom callouts for letterboxes (which are similar to geocaches). The letterboxes have names, which are sometimes quite long. We don't actually allow scrolling inside the callout content view, but we do shrink font sizes and truncate labels if necessary. I think the iOS Maps app just constrains the content view to a fixed, maximum width which is guaranteed to fit on a 320 unit wide screen. But that means that long place names are truncated. |
Oh I think I finally see what you meant in your original comment - you're saying that you supply SMCalloutView with a particular contentView, which turns out to make the callout too large, so the callout shrinks itself, which then causes the contentView to - overflow the callout probably? So you're saying it would be nice if the contentView in this situation was resized to fit the newly-smaller size. The only reason I'd be hesitant to do that would be that SMCalloutView uses contentView.frame.size as a "signal" to determine what the contentView's "desired" size is. If it then goes and changes the contentView size, then it's destroying that signal. Perhaps you could simply resize the contentView yourself according to the constrained view when necessary? |
We are using a variable width contentView (sized to fit text labels and other content). When SMCalloutView resizes itself to fit within the parent view (e.g., MKMapKit), it should resize the contentView as well. Here is a patch for the private presentCalloutFromRect method that adjusts the contentView's width to fit (we did not try to use a dynamic height):
The text was updated successfully, but these errors were encountered: