PDA

View Full Version : URGENT: content size exceeds screen resolution size!




ilx.mac
May 20, 2009, 03:26 AM
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!



Svinja
May 20, 2009, 03:49 AM
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:

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

ilx.mac
May 20, 2009, 04:30 AM
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!

BlackWolf
May 20, 2009, 04:41 AM
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?

ilx.mac
May 20, 2009, 04:43 AM
I didn't. I am new to scrollview. can you help me on how to create it?

ilx.mac
May 20, 2009, 04:53 AM
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!

Svinja
May 20, 2009, 05:03 AM
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

chbeer
May 20, 2009, 08:05 AM
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!)

ilx.mac
May 20, 2009, 08:22 AM
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!

Svinja
May 20, 2009, 08:44 AM
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..

chbeer
May 21, 2009, 02:23 AM
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.