scrollViewDidScroll
サブクラスのメソッドを呼び出してUIScrollView
も何も起こらないという問題があります。これが私のコードです:
AppDelegate.m
#import "ScrollView.h"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
CGRect screenRect = [[self window] bounds];
ScrollView *scrollView = [[ScrollView alloc] initWithFrame:screenRect];
[[self window] addSubview:scrollView];
[scrollView setContentSize:screenRect.size];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
ScrollView.m
#import "AppDelegate.h"
#import "ScrollView.h"
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
NSString *imageString = [NSString stringWithFormat:@"image"];
UIImage *image = [UIImage imageNamed:imageString];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[super addSubview:imageView];
}
return self;
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
NSLog(@"%f", scrollView.contentOffset.y);
}