Опит за прихващане на събитията при докосване на родителски UIView, който капсулира както UIScrollView, така и друг UIView (наслагване), които се намират един до друг (което означава един върху друг, в един и същ изглед на контейнер). Към момента просто се опитвам да отпечатам резултата от потвърждението на събитието touchesBegan на родителския UIView, но той хвърля EXC_BAD_ACCESS с тази грешка:
Program received signal: “EXC_BAD_ACCESS”.
warning: Unable to restore previously selected frame.
Data Formatters temporarily unavailable, will re-try after a 'continue'. (Not safe
to call dlopen at this time.)
Мисля, че целият съответен код трябва да е по-долу. Качих целия проект и на http://devmu.com/transfer/NoteMap.zip , ако така се вижда по-лесно.
loadView на UIViewController:
- (void)loadView {
[super loadView];
[[NSBundle mainBundle] loadNibNamed:@"ContainerView" owner:self options:nil];
ContainerView *container = self.containerView = [[ContainerView alloc] initWithFrame:[UIScreen mainScreen].applicationFrame];
self.view = container;
//[self.view addSubview:container];
[container release];
};
-the dealloc function releases the containerView
ContainerView:
@implementation ContainerView
@synthesize overlayView=_overlayerView, scrollView=_scrollView;
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
//setup scrollview
[[NSBundle mainBundle] loadNibNamed:@"GridScrollView" owner:self options:nil];
self.scrollView = [[GridScrollView alloc] initWithFrame:CGRectMake(0, 0, self.frame.size.width, self.frame.size.height)];
[self addSubview:self.scrollView];
//setup overlayview
NSArray *nibOverlayContents = [[NSBundle mainBundle] loadNibNamed:@"MapOverlayView" owner:self options:nil];
self.overlayView = [nibOverlayContents objectAtIndex:0];
[self addSubview:self.overlayView];
}
return self;
}
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
NSLog(@"ContainerView touchesBegan");
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
NSLog(@"ContainerView touchesEnded");
}
- (void)dealloc {
[self.overlayView release];
[self.scrollView release];
[super dealloc];
}
Имам отделни nib файлове за ContainerView (заредени от контролера) и това са два подизгледа, MapView и MapOverlayView (заредени от init на ContainerView). Не съм сигурен дали има значение... но nib файловете имат само препратка към съдържащите се изгледи. т.е. Собственикът на файла на ContainerView.xib е UIViewController и единственият му изглед е ContainerView. Собственикът на файла на MapView.xib и MapOverlayView.xib е ContainerView и съдържа две препратки към MapView и MapOverlayView (IBOutlets на ContainerView/собственика на файл).
На какво може да се дължи това?
Благодаря за всяка помощ.