I have following storyboard based design with constraints
I am adding this view to main view as follows
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"CompanyFundView" owner:nil options:nil];
CompanyFundView *view = [nibContents lastObject];
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
UIView *parent = mainWindow.subviews[0];
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
view.frame = CGRectMake(0, 0, screenWidth, screenHeight);
[parent addSubview:view];
As you can see the view isnt appearing inside the main view and not getting resized , what are the other constraints i need to add ?
Make sure you are adding NSLayoutConstraint
on a storyboard scene with width and height set to w:Any h:Any
I can see you are using w:Any Regular
The constraints are specific so it won't scale.
Use specific scene sizes when dealing with specific layout for a targeted device size
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.