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

Contentview with constraints fails #87

Open
hixfield opened this issue Jun 10, 2015 · 1 comment
Open

Contentview with constraints fails #87

hixfield opened this issue Jun 10, 2015 · 1 comment

Comments

@hixfield
Copy link

I embed a custom contentview in the smcallout.
Its gui is defined in a xib, and I have many constraints (autolayout).
When the constraints attach to the right side eg uilabel from left side 10p and right side 10p
then the label is stretched on de right side far beyond the right edge... All constraints
hooked to the right side get messed up. As a temp workarround I have replaced them by
constraints to the left + specify hardcode width constraint. But what is happening here?

@nfarina
Copy link
Owner

nfarina commented Jun 10, 2015

So the callout view doesn't do any kind of special "treatment" to contentView - it simply takes the frame.size on the contentView you assign and uses that, then adds it as a subview.

I'm not an expert on autolayout, but you might try adding your custom view as a subview of a "blank" UIView that you create in code with the frame of the size you want. Example:

UIView *contentView = [[UIView alloc] initWithFrame:CGRectMake(0,0,100,100)];
UIView *myViewFromXib = // however you construct this
[contentView addSubview:myViewFromXib];
calloutView.contentView = contentView;

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