Reputation: 30648
I have a viewController called "HaveScrollController", and this is something like this:
@interface HaveScrollController : UIViewController <UIScrollViewDelegate>{
IBOutlet UIScrollView *scrollView;
IBOutlet UIView *firstView;
IBOutlet UIView *secondView;
IBOutlet UIView *thridView;
IBOutlet UIView *fourthView;
}
@property (retain, nonatomic) UIScrollView *scrollView;
@property (retain, nonatomic) UIView *firstView;
@property (retain, nonatomic) UIView *secondView;
@property (retain, nonatomic) UIView *thridView;
@property (retain, nonatomic) UIView *fourthView;
@end
and the .m is something like this:
@synthesize scrollView,firstView,secondView,thridView,fourthView;
- (void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:scrollView];
scrollView.delegate = self;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView{
NSLog(@"scroll detected");
}
@end
I make all the connection to the IB already. And I wanna to use this controller in my "TestAppController", which is something like this, it don't use IB, and generate the interface using code:
@interface TestAppController : UIViewController <UIScrollViewDelegate,UIActionSheetDelegate, UITextFieldDelegate> {
HaveScrollController *scollViewController;
}
The .m is something like this in the loadView method:
scollViewController = [[HaveScrollController alloc] initWithNibName:@"HaveScrollView" bundle:nil];
[mainCanvas addSubview: buttomScollViewController.view];
self.view = mainCanvas;
[mainCanvas release];
When I try to scroll the view, but the "scroll detected" is not shown. What did I do wrong? thank you.
Upvotes: 0
Views: 2306
Reputation: 1782
Is scrollView
scrolling at all? It looks like you forgot to set the contentSize
:
scrollView.contentSize = CGSizeMake(320, 400);
Obviously, make sure the contentSize
is larger than scrollView's
frame so that the scrolling action kicks in.
Upvotes: 2