I开发者_如何学Go'm using the following code to load a xib in my UIView subclass named ImageWithCaptionView. I've specified in the xib Inspector the name of the view: ImageWithCaptionView.
However the if statement (isKindOfClass) is never true, and I've to remove it to make things work. What am I missing here ?
UINib *nib = [[UINib nibWithNibName:NSStringFromClass([ImageWithCaptionView class]) bundle:nil] retain];
NSArray *myArray = [nib instantiateWithOwner:self options:nil];
for (id currentObject in myArray) {
if ([currentObject isKindOfClass:[ImageWithCaptionView class]]) {
self = (ImageWithCaptionView *) currentObject;
break;
}
}
Check if the class is also set in the Custom Class field in the identity inspector tab.
精彩评论