I have several UILabel
inside the child view of a UIScrollView
. I believe I've set it up exactly like the functioning UIScrollView
I have in another view controller, only this one won't scroll. The contentSize
is set to larger than the scrollview frame
size and scrollview delegate
is set to self
. The views are wired up in Interface Builder and the UIScrollview
has scrolling enabled, bounces, user interaction and multiple touch enabled. The child UIView
also has user interaction enabled. Here is my code:
.h file
#import <UIKit/UIKit.h>
@interface CreditsViewController : UIViewController <UIScrollViewDelegate>
@end
.m file
#import "CreditsViewController.h"
@interface CreditsViewController ()
@property (nonatomic, strong) IBOutlet UIScrollView *scrollView;
@property (nonatomic, strong) IBOutlet UIView *contentView;
@end
@implementation CreditsViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.scrollView.delegate = self;
_scrollView.contentSize = _contentView.frame.size;
NSLog(@"scrollview frame size, contentview frame size: %f x %f, %f x %f", _scrollView.frame.size.width, _scrollView.frame.size.height, _contentView.frame.size.width, _contentView.frame.size.height);
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
NSLog(@"in scrollViewWillBeginDragging");
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSLog(@"in scrollViewDidScroll");
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
@end
I get scrollview frame size, contentview frame size: 240.000000 x 128.000000, 320.000000 x 568.000000 as the log printout but I never get the statements from the delegate methods. The scrollview is the only child of the view controller so it should be receiving the touch events when I try to scroll. What's going on?
您需要实现viewForZoomingInScrollView:并返回_contentView。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.