calloutview icon indicating copy to clipboard operation
calloutview copied to clipboard

Contentview with constraints fails

Open hixfield opened this issue 9 years ago • 1 comments

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?

hixfield avatar Jun 10 '15 18:06 hixfield

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;

nfarina avatar Jun 10 '15 20:06 nfarina