0
votes

I am working on an app that is using a few UIViewcontrollers with multiple UIViews. I am trying to setup autolayout but the UIViews are not scaling to the UIViewcontroller size. Can someone point me to a way to resolve this with out the need to redesign the app architecture?


So I have a UIViewController and a subview UIView (addNoteUIView)

When I am adding the subview to the viewController the subview Addnote View not resizing via auto layout to the bounds of the screen and it get cropped.

the subview does not resize to the bounds of the device

How to you fix the second UIView (add note view) to follow the bounds of the device?

EDIT

Thanks Vishal

I am setting the frame on viewdidload

[self.collectionView setFrame:self.view.frame];
[self.collectionView setNeedsLayout];

But, I am getting this behavior from the cells. Why is this happening? multiple bounds? see image with collection view cell error

my code for the collection item size

- (CGSize)collectionView:(UICollectionView *)collectionView
                  layout:(UICollectionViewLayout*)collectionViewLayout
  sizeForItemAtIndexPath:(NSIndexPath *)indexPath{

    CGRect screenRect = [_collectionView bounds];
    CGFloat screenWidth = screenRect.size.width;
    CGFloat screenHeight = screenRect.size.height;

    CGFloat cellWidth = (screenWidth / (_lcolumns)); //Replace the divisor with the column count requirement. Make sure to have it in float.
    CGFloat cellHeight = (screenHeight / (_lrows));

    if(cellWidth < cellHeight)
        return  CGSizeMake(cellWidth, cellWidth);
    else
        return  CGSizeMake(cellHeight, cellHeight);

}
1
its not clear what you want to achieve. show us some working code or layout.luckyShubhra
show us a screenshot of your problem. It's hard to understand what's the problem as a wholeDark Innocence
I updated the question above - hope that makes it a bit clearer?Koen

1 Answers

0
votes

Its not resize using autolayout you need to set frame OR you need to give constraints programatically.