Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ilx.mac

macrumors member
Original poster
Mar 10, 2009
63
0
Hi there, i have a UIView in place. i am displaying some labels & textview. Its exceeding the screen resolution size. Is there some thing to scroll & view the entire screen. I have attached my screen for reference.

Thanks in Advance!
 

Attachments

  • Picture 1.png
    Picture 1.png
    602.5 KB · Views: 80
UIScrollView

you add UISrollView to your view and then add all the controls to your scrollView. You must also set contentSize of the UIScrollView

Example:
Code:
// Create scroll view(in viewDidLoad)
UIScrollView *scrollViewTemp=[[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
scrollViewTemp.backgroundColor=[UIColor colorWithWhite:1.0f alpha:0.0f];
self.scrollView=scrollViewTemp;
[self.view addSubview:self.scrollView];
[scrollViewTemp release];

// Create your controls here and add them to the scrollView(with addSubview)

// Set the scrolling height
self.scrollView.contentSize=CGSizeMake(320,HEIGHT);
 
thanks for the input svinja. I tried using your code.

self.scrollView=scrollViewTemp;

But i am getting error 'scrollview is some thing not a structure or union'.

Any Inputs/Suggestions Please!
 
thanks for the input svinja. I tried using your code.

self.scrollView=scrollViewTemp;

But i am getting error 'scrollview is some thing not a structure or union'.

Any Inputs/Suggestions Please!

did you even create the scrollView property?
 
I didn't. I am new to scrollview. can you help me on how to create it?
 
Now Finally I got it to work.

I Placed a scrollview on UIView using Interface Builder and the code below helped me to scroll.

myScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
myScrollView.contentSize = CGSizeMake(1800.0, 2300.0);
[setvalue addSubview:myScrollView];
[myScrollView release];

Thanks for the response guys! Have a good Day!
 
scrollView is a property,
If you have self. in front of the word, it means it is a property(something like global variable)

And one suggestion since i see you are begginer, stay away from interface builder, create your controls in code...just my opinion
 
scrollView is a property,
If you have self. in front of the word, it means it is a property(something like global variable)

ugh!! property != global variable!! property = field in object to store data/reference.

And one suggestion since i see you are begginer, stay away from interface builder, create your controls in code...just my opinion

ugh!! WRONG! As a beginner you should read one (or better more) books on Cocoa and iPhone dev. and/or have a look at the examples from Apple. And you should read about how the IB works before using it... but you should not avoid it!! (my opinion!)
 
If [self.scrollview .. this appears then what u said was the thing, i supposed to do. But I am not getting that property after 'self.'. Thats why i opted to design it by IB. Is there any other way to do so. Please help with some code samples.

Thanks in advance!
 
ugh!! property != global variable!! property = field in object to store data/reference.
i didnt write anywhere that property=global variable!!, i wrote "something like global variable" because i was trying to explain to him with something familiar since it is obvious he is beginner, but thanks for correcting me :)

ugh!! WRONG! As a beginner you should read one (or better more) books on Cocoa and iPhone dev. and/or have a look at the examples from Apple. And you should read about how the IB works before using it... but you should not avoid it!! (my opinion!)
Everyone has an opinion, you cant say for opinion that is wrong, of course, every begginer should read some books but IB surely didnt help me in the beggining, nobody in my office uses IB anymore, too much time for nothing..
 
i didnt write anywhere that property=global variable!!, i wrote "something like global variable" because i was trying to explain to him with something familiar since it is obvious he is beginner, but thanks for correcting me :)

You are partly right with "global variable" because it is global to the object. But the problem for a beginner is, that he then tries to access the variable from another object and can't do that. Then he's puzzled.

Everyone has an opinion, you cant say for opinion that is wrong, of course, every begginer should read some books but IB surely didnt help me in the beggining, nobody in my office uses IB anymore, too much time for nothing..

I didn't want to say your opinion is wrong but: for my opinion it is wrong to do everything without IB. Especialy for beginners it is a lot easier to "design" the screen and only code the logic behind it.

My opinion is for beginner is: Buy and read Kochans Book 2nd edition. That is a gread intro to objective-c and he shows how to code a small iPhone program in one of the last chapters.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.