I have a strange mistake. I have a UIViewController with a UIScrollView embedded inside a UIView. There are several images inside UIScrollview, but I need more space, so I want to put some images under the current ones. I did all the usual things to create and initialize my ScrollView, but instead of scrolling in the UP / DOWN direction, it scrolls LEFT / RIGHT ... What happens?
- I declared "UIScrollViewDelegate" in .h
My property @property (weak, nonatomic) IBOutlet UIScrollView *scrollViewContent;is related to my scrollview in IB
My ContentSize is declared as:, self.scrollViewContent.contentSize= CGSizeMake(self.scrollViewContent.frame.size.width, 1000);and whether I declare it in ViewDidLoad or viewDidLayoutSubviews does not change anything.
I set self.scrollViewContent.delegate = self;
to ViewDidLoad
UPDATE
Interestingly, I tried setting up ContentSize and then printing it to the console. As it turned out, the “Height” attribute always returns 0. Also, note that I set the “Width” to 1500, but it prints 2000. I do not use an auto-cutter.
[self.scrollViewContent setContentSize:CGSizeMake(1500, 2000)];
NSLog(@"contentSize width %f", self.scrollViewContent.contentSize.width);
NSLog(@"contentSize height %f", self.scrollViewContent.contentSize.height);
Result:
"contentSize width 2000.000000" "contentSize height 0.000000"
UPDATE 2 If I take the same code and the same Xib in another project, it works fine ... what is wrong with my actual project?
source
share