Попытка перехватить события касания в родительском 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
КонтейнерВью:
@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];
}
У меня есть отдельные файлы пера для ContainerView (загружаемые из контроллера), и это два подпредставления, MapView и MapOverlayView (загружаемые из инициализации ContainerView). Не уверен, что это должно иметь значение... но в файлах пера есть только ссылка на содержащиеся в них представления. т.е. Владельцем файла ContainerView.xib является UIViewController, а единственным представлением является ContainerView. Владельцем файла MapView.xib и MapOverlayView.xib является ContainerView, и он содержит две ссылки на MapView и MapOverlayView (IBOutlets владельца ContainerView/файла).
Что может быть причиной этого?
Спасибо за любую помощь.