UIScrollview only scrolls when empty - iphone

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.

Related

ScrollView start scroll only second time that the view appear

I've a problem with my view in iOS7 with autolayout.
This is my structure:
The UITextView content is dynamic so I fit his contentSize dynamically in the viewDidLoad.
In my viewDidAppear I try to fit the contentSize of the MainScroll and the mother view calculated by the sum of UIScrollView height (the little one), Pager height and UITextView height. I logged this height and it returned the correct size: 1300px but the view doesn't scroll.
If I change tab and return here the scroll start to scroll, I've tried to put every piece of code in the viewDidLoad but it doesn't work.
Can you help me?
Thanks and sorry for bad English.
Try selecting it and then selecting "reset to suggested constraints" in the storyboard. :).

ScrollView in iPhone interfacebuilder

I have put 14 items in scroll view but it gets stuck after 6 items. I have not put any code, just did all from interface builder (items are arranged vertically). I can see the items below but it jumps to 6 items when I release the touch. It is not that the scroll view is not working, it is just not showing as much I want it to show.
Has any-body got any idea what is happening? any help is appreciated.
You should set the content size of your scrollview.
e.g.
[scrollview setContentSize:CGSizeMake(scrollview.contentSize.width, heigth)];
Where set height that contains all your sub controls in scrollview.
Scrollview content size is not set properly. Use setContentSize: to set the content size of the scrollview
You added the content into scrollview so now you have to make scroll know to what size it shoul scroll and show the content
Do
Set an outlet and then add this code in viewDidLoad
[scrollview setContentSize:CGSizeMake(width, height)];
From Docs
contentSize
The size of the content view.
#property(nonatomic) CGSize contentSize
Discussion
The unit of size is points. The default size is CGSizeZero.
Here is a nice tutorial since you are a beginner .
may be its too late, but here is how i solved it:
put the items in a UIView and stretch that view as much as it need to be stretched.
put that UIView in the scrollview.
put a scroll view in the main uiview, the height and width will be similar to uiview.

How to make a scrollable view in iOS?

i am looking to create an "options" page for my application and because they are many , the screen of the phone is not enough to show.
So i need the user to be able to scroll down the view to see more options till the last. I know i should use the scrollview , but i dont know how.
All the tutorials i ve found are about scrolling all over the screen , zooming , scrolling from left to right , but nothing on how u can create a simple page scrolling up and down.
How exactly do i do that? Do i make many .nib files and somehow i connect them? Do i make a big .nib file?
Can someone guide me to a tutorial on that?
Use ContentSize property of UIScrollView to scroll what ever area you want. i.e.
take UIScrollView add it on UIView with exist height of iPhone. i.e. max 460.0
So ScrollView frame will be max (0,0,320.0,460.0).
Now after adidng ScrollView to View set ContentSize property to upto scrollable area.
[self.mainScrollView setContentSize:CGSizeMake(self.mainScrollView.frame.size.width, 1000.0)];
UIScrollView *mainScroll = [[[UIScrollView alloc]initWithFrame:CGRectMake(x,y,w,h)]autorelease];//scrollview width and height
mainScroll.scrollEnabled = YES;
mainScroll.userInteractionEnabled = YES;
mainScroll.showsVerticalScrollIndicator = YES;
mainScroll.contentSize = CGSizeMake(width,height);//width and height depends your scroll area
..........
//add subviews to your scrollview.....
[mainScroll addSubview:view1]
............
[mainScroll addSubview:view2]
..............
[mainScroll addSubview:view3]
[self.view addSubview:mainScroll];
Note :: contentSize property determines your scroll
area.Scrolling
enabled only if your scrollview content larger than scrollview height..
You could use a Table View with static Cells, that will scroll automatically if it needs to, much easier. Also with a Table View you can choose to scroll up, down, left, right, set bouncing etc from the Attributes Inspector.
Make only 1 nib file.
give height of scroll view large as you want.
then place your buttons , textfeild on scroll view
There are two ways :
make settings bundel for your app check this Press Me
to make UITableView with custom cells >> it is easy if you use
Interface Builder Press Me

UIScrollView only scrolls with text

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.

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)];