 |
 |
|
 |
02-11-2010, 01:54 PM
|
#1 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
Help with UIScrollView
My objective is simple. Display an image that is 320x2000. User will scroll down the image, no zooming required.
I'm having a lot of problems with this.
In Interface Builder I made a scroll view, set it to 320x2000. I put an image view inside of it, specified my image for the image view.
in my .m file i have:
#import "TestViewViewController.h"
@implementation TestViewViewController
@synthesize scrollView2;
- (void)viewdidLoad
{
[scrollView2 setContentSize:CGSizeMake(320, 2000)];
}
What else am i missing?
|
|
|
02-11-2010, 01:56 PM
|
#2 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
|
Is the UIImageView 320x2000?
|
|
|
02-11-2010, 02:02 PM
|
#3 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
Quote:
Originally Posted by harrytheshark
Is the UIImageView 320x2000?
|
Yes
|
|
|
02-11-2010, 02:03 PM
|
#4 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
|
And everything is hooked up correctly in IB?
|
|
|
02-11-2010, 02:04 PM
|
#5 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
Quote:
Originally Posted by harrytheshark
And everything is hooked up correctly in IB?
|
What do I need to connect in IB. I have nothing connected now.
|
|
|
02-11-2010, 02:07 PM
|
#6 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
|
You need to connect the UIScrollView to "scrollView2".
Your .h file should look something like:
Code:
#import <UIKit/UIKit.h>
@interface TheUIViewController : UIViewController {
UIScrollView * scrollview2;
}
@property (nonatomic, retain) IBOutlet UIScrollView * scrollview2;
@end
|
|
|
02-11-2010, 02:12 PM
|
#7 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
|
|
|
02-11-2010, 02:32 PM
|
#8 (permalink)
|
|
Registered Member
Join Date: Dec 2008
Location: UK
Posts: 1,886
|
Right. A few things.
when the view loaded, viewDidLoad is called, not viewdidload (case sensitive).
Another thing. The "view" outlet needs to be set to the UIView, not the UIImageView.
In the .h file, you should have:
Code:
@interface TestViewViewController : UIViewController {
UIScrollView *scrollView2;
}
@property (nonatomic, retain) IBOutlet UIScrollView * scrollView2;
@end
What I gave you was just an example, not literally what it should be. Sorry for the confusion.
In IB, you then need to hook up the "scrollView2" outlet from "File's Owner" to the UIScrollView.
You also need to make sure that the UIScrollView is only 480 pixels high. Otherwise it won't scroll.
Tom
|
|
|
02-11-2010, 03:43 PM
|
#9 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
Quote:
Originally Posted by harrytheshark
Right. A few things.
when the view loaded, viewDidLoad is called, not viewdidload (case sensitive).
Another thing. The "view" outlet needs to be set to the UIView, not the UIImageView.
In the .h file, you should have:
Code:
@interface TestViewViewController : UIViewController {
UIScrollView *scrollView2;
}
@property (nonatomic, retain) IBOutlet UIScrollView * scrollView2;
@end
What I gave you was just an example, not literally what it should be. Sorry for the confusion.
In IB, you then need to hook up the "scrollView2" outlet from "File's Owner" to the UIScrollView.
You also need to make sure that the UIScrollView is only 480 pixels high. Otherwise it won't scroll.
Tom
|
Ok I will try it when I get back home. Thank you.
|
|
|
02-11-2010, 06:14 PM
|
#10 (permalink)
|
|
Elegance is Infinite
iPhone Dev SDK Supporter
Join Date: Jan 2010
Location: Bay Area, CA
Posts: 677
|
when i make scroll views i do
myScrollView.frame = CGRectMake (x,y,width,height);
is that wrong?
I see you using
[myScrollView setContentSize:CGSizeMake(320, 2000)];
Thanks
|
|
|
02-12-2010, 07:39 PM
|
#11 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
Okay, this is my code in my .m file:
#import "TestViewViewController.h"
@implementation TestViewViewController
@synthesize scrollView2;
- (void)viewDidLoad
{
[scrollView2 setContentSize:CGSizeMake(320, 2000)];
[scrollView2 setScrollEnabled:YES];
}
And it's returning an error on the @synthesize line saying "No declaration of property "scrollView2" found in the interface
|
|
|
02-12-2010, 08:44 PM
|
#12 (permalink)
|
|
Registered Member
Join Date: Feb 2010
Posts: 24
|
K, i figured it out :-)
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 247 |
| 22 members and 225 guests |
| @sandris, ADY, beleg_1998, Dani77, diyora, FAED, fredidf, F_Bryant, iDifferent, JamesCahall, JasonR, mer10, Oral B, prchn4christ, smithdale87, Speed, spiderguy84, stekki, tgjorgoski, Touchmint, twerner, vigu360 |
| Most users ever online was 1,187, 10-11-2011 at 08:09 AM. |
» Stats |
Members: 158,880
Threads: 89,228
Posts: 380,755
Top Poster: BrianSlick (7,129)
|
| Welcome to our newest member, @sandris |
|