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

using CalloutView with OHAttributedLabel #23

Closed
haashem opened this issue Jan 10, 2013 · 5 comments
Closed

using CalloutView with OHAttributedLabel #23

haashem opened this issue Jan 10, 2013 · 5 comments

Comments

@haashem
Copy link

haashem commented Jan 10, 2013

Im trying to use OHAttributedLabel in my app.
this class lets me to attribute my text and can fire my desired method after tapping your special attributed text.(like hypelinks) this API uses UILabel for its tag processing in text.
I want to show a callout view after touching these texts.
but it seems callout view doesn't appear after touching! (the method fires).

-(void)popOutCalloutView
{

calloutView = [SMCalloutView new];
calloutView.delegate = self;
calloutView.title = @"wow!!";
[calloutView presentCalloutFromRect:_basicMarkupLabel.frame inView:_basicMarkupLabel constrainedToView:_basicMarkupLabel permittedArrowDirections:SMCalloutArrowDirectionDown animated:YES];

}

you can download my test project from here :
http://upload.ugm.ac.id/775OHAttributedLabel-master%202.zip

@haashem
Copy link
Author

haashem commented Jan 11, 2013

please refer to this updated link:
http://upload.ugm.ac.id/133OHAttributedLabel-master%202.zip

I want to use this callout view for attributed texts.
so I want after touching every attributed text, the callout view appears above the text. but it seems there is something wrong that I can't figure out!
How can I display it above every attributed text?

[calloutView presentCalloutFromRect:_demoLabel.frame inView:_demoLabel constrainedToView:_demoLabel permittedArrowDirections:SMCalloutArrowDirectionDown animated:YES];

Screen Shot 2013-01-11 at 7 16 42 PM

@nfarina
Copy link
Owner

nfarina commented Jan 11, 2013

Hello,

What's happening here is that you're asking the popup to display pointing at the entire OHAttributedLabel surface, which it's doing correctly.

What I think you actually want is to tell the popup to appear pointing at the CGRect defined by just the area of the link that was clicked. However, OHAttributedLabel doesn't seem to support giving you the rect of a particular link.

One thing you might try is to intercept and track touches yourself in the superview of your OHAttributedLabel to figure out the X/Y position of where the user's finger is, then you could present the callout above that point.

Anything else would require hacking OHAttributedLabel, which might be a bit complex.

I'm closing this issue as I believe SMCalloutView is behaving correctly here.

Good luck!

Nick

@haashem
Copy link
Author

haashem commented Jan 14, 2013

thanks for your guides
I followed you response and could solve the problem.
I used
CGRect CTRunGetTypographicBoundsAsRect(CTRunRef run, CTLineRef line, CGPoint lineOrigin);
to find the exact position of links.
so everything worked well. but after adding the label to a UIScrollView (because the string in the label is very long).
another problem raised. the SMCalloutView locks on a specific position, and all the time appears above that.
I couldn't understand why acts like this. so I've uploaded them and posted a link in #24 issue.
I appreciate if you could tell me why it is happening!!

Screen Shot 2013-01-14 at 10 27 38 PM
Screen Shot 2013-01-14 at 10 31 06 PM

@nfarina
Copy link
Owner

nfarina commented Jan 14, 2013

That's great that you got it working! I didn't know about CTRunGetTypographicBoundsAsRect, that's exactly what was needed.

What view are you adding the callout to? If the result of CTRunGetTypographicBoundsAsRect is an x/y position in the coordinate system of the label, then you'll probably want to make sure the calloutview is presented inside the scrollview somewhere.

@haashem
Copy link
Author

haashem commented Jan 16, 2013

touching delay solved!
the solution is here:
http://stackoverflow.com/questions/3642547/uibutton-touch-is-delayed-when-in-uiscrollview

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

No branches or pull requests

2 participants