最新のSDKとXCode 4.2でiOSアプリケーションを開発しています。カスタムXIBを使用したカスタムUIView:IBOutletsが機能しない
カスタムUIViewでカスタムXIBを使用したいと考えています。
マイカスタムUIViewの:
@interface CoordinateView : UIView {
/**
*/
ARGeoCoordinate *geoCoordinate;
/**
*/
IBOutlet UILabel* title;
/**
*/
IBOutlet UILabel* subTitle;
/**
*/
IBOutlet UIImageView* image;
}
が実装:
@implementation CoordinateView
@synthesize geoCoordinate;
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// Initialization code.
//
NSArray* topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"CoordinateView" owner:nil options:nil];
for(id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[CoordinateView class]])
{
[self addSubview:currentObject];
break;
}
}
}
return self;
}
- (id)initForCoordinate:(ARGeoCoordinate *)coordinate
{
self.geoCoordinate = coordinate;
CGRect theFrame = CGRectMake(0, 0, BOX_WIDTH, BOX_HEIGHT);
self = [self initWithFrame:theFrame];
if (self)
{
title.text = geoCoordinate.title;
image.image = [UIImage imageNamed:[NSString stringWithFormat:@"03%d.jpg", geoCoordinate.id]];
}
return self;
}
私はinitWithCoordinate
メソッドを使用CoordinateView
を初期化します。
title.text = geoCoordinate.title;
私は 'リンク' IBOutletsにInterface Builderのを使用しました:
デバッグ私はtitle
がここinitWithCoordinate
内部nilであることを発見しました。
私は間違っていますか?
問題はXCode 9とiOS 11ではまだ存在しますが、手順3のダイアログボックスでは表示されません。あなたはあなたの答えを更新していただけますか? – iOSdev