I'm developing an iOS 5+ app with latest SDK.
I have created a custom UIView (TopMenuView
) with a custom XIB. On Interface Builder I have changed, on this XIB, UIView
class to TopMenuView
. I haven't set any File's Owner
.
On TopMenuView.m
I have:
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
NSLog(@"init with coder: %d", counter);
counter++;
// Add custom XIB
NSArray *topMenuView = [[NSBundle mainBundle] loadNibNamed:@"TopMenuView"
owner:nil
options:nil];
UIView *nv = [topMenuView objectAtIndex:0];
[self addSubview:nv];
}
return self;
}
Using Interface Builder I have added a UIView
to a UIViewController
and changed this UIView
class to TopMenuView
.
But, when I run the app, I get this log message 4251 times:
2013-10-13 20:49:34.078 MyProject[470:c07] init with coder: 0
And then, I get an EXC_BAD_ACCESS
here:
NSArray *topMenuView = [[NSBundle mainBundle] loadNibNamed:@"TopMenuView"
owner:nil
options:nil];
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…