UIScrollView only scrolls with text - iphone

I recently updated my xcode to 4.5 but now my UIScrollView Doesn't work anymore, in my previous xcode I made the scrollview at the exact same way and placed a imageview background and some buttons in it, they scroll along when I scroll.
Now with this new xcode when I place something in it, it doesn't scroll at all. Only when I put textview in it and make the text longer then the screen then it will scroll, but even then when I place a button on it the button won't scroll along, just the text. It's realy annoying and I don't know what Im doing wrong.. I've been trying to find a solution to this all day.
my ScrollView is placed in my view and got size 320,480.
in my ViewDidLoad I have:
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320, 481)];
I also have a picture to make my setup more clear, When I run the project in this picture it does scroll because of the text length. the image background is 320x960 but the picture doesn't scroll along it should go to the bottom where to color becomes more dark.. I hope you understand what I mean.
Extra
I made a video showing what I do, showing that it doesnt scroll when I put something in it
http://www.youtube.com/watch?v=rzYTWLiIC8g&feature=youtu.be

set your scrollView contentSizes height more than its original height then it would be vertically scrollable for sure.
Try this -
[scroller setContentSize:CGSizeMake(320, 800)];
Then see it scrolls or not.

Related

Nested uiScrollViews with Cross-Directional Scrolling

I would like to nest two uiScrollViews, I want to put a uiImageView into one and have it scroll horizontally (Scroller A). This is paged and contains images – I have this working OK already. I need to have another uiScrollView (Scroller B) that contains the above scroller A and also other content, like logo, text and buttons. I would like scroller B to be able to scroll vertically (scrolls all content including scroller A ).
Please see image for clarification, red arrows show scroller A, blue is scroller B
Image showing more details
I’m not sure how to add these and what order the scrollers need to be added, I have attempted this a couple of times with strange results, I'm hoping someone can point me in the right direction please.
A similar app would be the apple app store app.
Keep a vertical scroll view add a fixed size view (which contains your horizontal scrollview) on it and increase its content size accordingly.each view will have Preloaded horizontal scroll view.
for(int i=0;i<10;i++)
{
y=i*110;
secondScroll=[[UIScrollView alloc]initWithFrame:CGRectMake(x, y, 320, 100)];
[secondScroll setContentSize:CGSizeMake(600, 45)];//to enable scrolling content size is kept more the 320
secondScroll.backgroundColor=[UIColor greenColor];
[self.firstScroll addSubview:secondScroll];
[secondScroll release];
[self.firstScroll setContentSize:CGSizeMake(320, self.firstScroll.contentSize.height+110)];
}
first scroll is added on xib second scroll is created by code

UIScrollview only scrolls when empty

I updated xcode to 4.5 but now when I make à UIScrollview it stops scrolling as soon I place something in the scroll like à label or button, when I remove them the scrolls works again
someone knows the fix?
Code
My ScrollView is 320 by 430 and in my viewdidload I use:
[scroller setScrollEnabled:YES];
[scroller setContentSize:CGSizeMake(320, 481)];
edit
I just discovered that in landscape mode it does scroll so maybe I am setting my content size wrong? :S
edit#2
It works now if I make a text view in the scrollview and make the text larger then the screen, but When I place a button into it the button doesnt scroll along ..
Extra
I made a video showing What I do hope someone can tell me what im doing wrong
http://www.youtube.com/watch?v=rzYTWLiIC8g&feature=youtu.be
"Use Autolayout" was on it has to be off and it will be fixed thanks for all your support.
You don't have enough content for scrolling.
Please add more content text. Then only it scroll.
Set the contentSize of your scroll view to the size of the content, eg. if you have 10 rows of buttons, each row's height let's say 40px, and padding 5px, the height (height if you are putting the content vertically, width if horizontally) of the contentSize of the scroll view is: 10*45.0f+5.0f. If this doesn't help, then show us your code.

IPhone App: UIScrollView scrolls to bottom when it loads

I have a detail view for a contact. The last field is a Textview that can be as short as 1 line and as long as 20. in the viewDidLoad method I use:
scrollView.contentSize = self.view.frame.size;
My problem is that when the data is displayed, the scroll view scrolls to the bottom on its own. Obviously I would like it to start at the top.
I used the Content offset with the bottom value set to about 300 to allow the view to even be able to scroll down far enough. I have tried to disable scrolling until the load is finished but then it just locks you at the bottom.
As you can probably tell I am new at iPhone Programming. Any ideas?
Set contentOffset to 0.
Then, go and read the docs. you're using the scroll view completely wrong.
UITextView is scrollable, so it's unclear why you're sticking it in a scroll view.

iphone, need to put many text boxes on the view, how to scroll down to view more content?

iphone, need to put many text boxes on the view, how to scroll down to view more content? I actually put buttons and labels on the ScrollView, but the scrolling doesn't work. Do I need to write any code for that, any example?
Thanks.
You need to set the contentSize property of the UIScrollView to something bigger than its frame size.
[aScrollView setContentSize:CGSizeMake(320, 1000)];

UIScrollView not showing scroll indicator

I have a UIScrollView which I create and size dynamically using...
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width , length);
I then add subviews to the UIScrollView.
I do have scrollView.showsVerticalScrollIndicator = YES;
When scrolling the scroll indicator never appears.
Even if I call [scrollView flashScrollIndicators] nothing happens.
Ideas?
Had the same problem and couldn't find the cause. The last answer gave the final hint: whenever I added new subviews I first removed all existing subviews from the scrollview (and apparently also the scroll indicators).
After checking in my loop, if the subview really was of the kind I wanted to be removed the scroll indicators showed up:
for (NSObject * subview in [[[scrollView subviews] copy] autorelease]) {
if ([subview isKindOfClass:[MySubView class]]) {
[(MySubView*)subview removeFromSuperview];
}
}
Update: changed code to Nikolai's suggestion
When I've dealt with this before, in my implementation of a grid, I would occasionally get some cells over the top of the scroll indicator. To fix this I am now inserting subviews at index 0 rather than adding them, which adds them to the top. So try something like this:
[scrollview insertSubview:subview atIndex:0];
For me, the horizontal indicator had mysteriously disappeared in my app on iOS 7. Later found out that for some strange reason, I had to enable both Shows Horizontal Indicator and Shows Vertical Indicator to make the horizontal one show up. If I set it to not show the vertical indicator, it would also not show horizontal indicator.
I fix this by adding this code after add new subview:
self.showsVerticalScrollIndicator = NO;
self.showsVerticalScrollIndicator = YES;
It will also happen (at least in the case of a UITableView) if the contentSize is too small for the table view to scroll. If you have enabled bouncing, then the tableview does not actually scroll and does not display the indicators therefore. Try fitting more content inside.
It can happen also if the parent of the scrollview is smaller horizontally than the scroll view itself :
The scroll bar is stuck to the right side of the ScrollView / TableView and this right side is not visible due to the parent bounds ( with a clipToBounds hidding it for instance).
I've seen this issue so I share it in case it can help.
Just check the width of your ScrollView's frame not to be bigger than the width of its parent view frame.
Two conditions,
If you are using a storyboard
If you are using a UITableView inside a UIViewController
Then, you should check your indicator insets are set to 0 (or any other number that is relevant to your autolayout):
Noticed this when the UIScrollView was a 48 px tall horizontal band, scrollable horizontally. Maybe Cocoa decides the area is too small for a scroll indicator...