I am running into a very annoying problem: I am creating an UIScrollView that containes an UIView that contains some buttons. The UIView with buttons work fine. But the UIScrollView, no matter what I do with it, when touched, crashes. It doesn't make any difference it's empty or not. It keep开发者_开发问答s crashing.
I am very lost and don't know what else to try. Thanks very much.
In the viewController.h
@interface tagstestViewController : UIViewController <UIScrollViewDelegate> {
UIScrollView *scrollViewContainer;
}
@property (nonatomic, retain) UIScrollView *scrollViewContainer;
In the viewController.m:
UIScrollView *scv = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0, 320, 200)];
scv.backgroundColor = [UIColor blackColor];
scv.autoresizingMask = UIViewAutoresizingFlexibleHeight;
scv.bounces = YES;
scv.scrollEnabled = YES;
scv.clipsToBounds = YES;
scv.delegate = self;
[self setScrollViewContainer:scv];
[scv release];
[self.view addSubview:scrollViewContainer];
Are you releasing your viewController right after you add its view into the view hierarachy? Because if you do that, I noticed that even though the application keeps running fine, if you use "scv.delegate = self", it will crash when it tries to deliver the delegated messages to the viewController.
精彩评论