0
我只想在viewcontoller的xib或stroy board上加载自定义视图(使用xib)。最佳做法也是这样做。如何使用xib或故事板上的xib加载自定义视图
我已经在下面使用了awakeAfterUsingCoder函数代码。
(id) awakeAfterUsingCoder:(NSCoder*)aDecoder
{
BOOL theThingThatGotLoadedWasJustAPlaceholder = ([[self subviews] count] == 0);
if (theThingThatGotLoadedWasJustAPlaceholder)
{
CustomView* theRealThing = (id) [CustomView view];
theRealThing.frame = self.frame;
theRealThing.autoresizingMask = self.autoresizingMask;
return theRealThing;
}
return self;
}
但使用此功能后,我的awakeFromNib开始多次调用。
请注意。