Using storyboard, I added, Scrollview -> View -> CollectionView.
my_collxn_view frame size is, (5, 200, 310, 368), my_view frame size is, (0, 0, 320, 568), my_scroll_view frame size is, (0, 0, 320, 568)
I am having 10 Cells. So Content size is too large. I don't know how to expand UICollectionView frame size through coding. Kindly guide me. I have tried something. My coding is below.
First Attempt
func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize
{
my_collxn_view.frame.size.height = my_collxn_view.contentSize.height //635.0
my_view.frame.size.height = 200 + my_collxn_view.frame.size.height //835.0
my_scroll_view.contentSize = CGSizeMake(320, my_view.frame.size.height) //Scrolling
my_collxn_view.frame = CGRectMake(5, 200, 310, my_collxn_view.frame.size.height) //Not Expanding
return CGSizeMake(150, 205) //CELL Size
}
Second Attepmt
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
my_collxn_view.frame.size.height = my_collxn_view.contentSize.height //635.0
my_view.frame.size.height = 200 + my_collxn_view.frame.size.height //835.0
my_collxn_view.frame = CGRectMake(5, 200, 320, my_collxn_view.frame.size.height) //Not Expanding
my_view.frame = CGRectMake(0, 0, 320, my_view.frame.size.height) //Not Expanding
my_scroll_view.contentSize = CGSizeMake(320, my_view.frame.size.height) //Scrolling
}
Updated
my_view.setTranslatesAutoresizingMaskIntoConstraints(true)
my_collxn_view.setTranslatesAutoresizingMaskIntoConstraints(true)
I have used the above two lines. Exact output received. But, Some warnings has been displayed in debug area.
Warning
2015-04-21 18:43:52.974 E Commerce[9475:1673654] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSIBPrototypingLayoutConstraint:0x7fcf6958a010 'IB auto generated at build time for view with fixed frame' V:|-(200)-[UICollectionView:0x7fcf6a84b000] (Names: '|':UIView:0x7fcf6957abe0 )>",
"<NSIBPrototypingLayoutConstraint:0x7fcf6958a0b0 'IB auto generated at build time for view with fixed frame' V:[UICollectionView:0x7fcf6a84b000(368)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7fcf696745c0 h=--& v=--& UICollectionView:0x7fcf6a84b000.midY == + 517.5>"
)
Will attempt to recover by breaking constraint
<NSIBPrototypingLayoutConstraint:0x7fcf6958a010 'IB auto generated at build time for view with fixed frame' V:|-(200)-[UICollectionView:0x7fcf6a84b000] (Names: '|':UIView:0x7fcf6957abe0 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-04-21 18:43:52.978 Test_work[9475:1673654] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSIBPrototypingLayoutConstraint:0x7fcf6958a0b0 'IB auto generated at build time for view with fixed frame' V:[UICollectionView:0x7fcf6a84b000(368)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7fcf69674630 h=--& v=--& V:[UICollectionView:0x7fcf6a84b000(635)]>"
)
Will attempt to recover by breaking constraint
<NSIBPrototypingLayoutConstraint:0x7fcf6958a0b0 'IB auto generated at build time for view with fixed frame' V:[UICollectionView:0x7fcf6a84b000(368)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-04-21 18:43:52.980 Test_work[9475:1673654] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSIBPrototypingLayoutConstraint:0x7fcf6958a6c0 'IB auto generated at build time for view with fixed frame' V:|-(0)-[UIView:0x7fcf6957abe0] (Names: '|':UIScrollView:0x7fcf6957a8b0 )>",
"<NSIBPrototypingLayoutConstraint:0x7fcf6958a760 'IB auto generated at build time for view with fixed frame' V:[UIView:0x7fcf6957abe0(568)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7fcf69674910 h=--& v=--& UIView:0x7fcf6957abe0.midY == + 442.5>"
)
Will attempt to recover by breaking constraint
<NSIBPrototypingLayoutConstraint:0x7fcf6958a6c0 'IB auto generated at build time for view with fixed frame' V:|-(0)-[UIView:0x7fcf6957abe0] (Names: '|':UIScrollView:0x7fcf6957a8b0 )>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2015-04-21 18:43:52.990 Test_work[9475:1673654] Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints)
(
"<NSIBPrototypingLayoutConstraint:0x7fcf6958a760 'IB auto generated at build time for view with fixed frame' V:[UIView:0x7fcf6957abe0(568)]>",
"<NSAutoresizingMaskLayoutConstraint:0x7fcf69674980 h=--& v=--& V:[UIView:0x7fcf6957abe0(885)]>"
)
Will attempt to recover by breaking constraint
<NSIBPrototypingLayoutConstraint:0x7fcf6958a760 'IB auto generated at build time for view with fixed frame' V:[UIView:0x7fcf6957abe0(568)]>
Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
Kindly guide me.