UIButton から継承するいくつかの追加のプロパティを持つカスタム ボタン クラスを作成しました。通常のボタンで次のようなビューに追加されます。
EFButton *btn = [EFButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(500, 100, 100, 44);
btn.backgroundColor = [UIColor lightGrayColor];
btn.userInteractionEnabled = NO;
[self.view addSubview:btn];
UIButton *nBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
nBtn.frame = CGRectMake(500, 100, 100, 44);
nBtn.backgroundColor = [UIColor lightGrayColor];
nBtn.userInteractionEnabled = NO;
[self.view addSubview:nBtn];
次のようにビュー内のオブジェクトをループします。
for (id view in self.view.subviews)
{
if ([view isKindOfClass:[EFButton class]])
{
//** dsnt come here **
NSLog(@"EFButton Class");
EFButton *btn = view;
}
if ([view isKindOfClass:[UIButton class]])
{
//** come here **
NSLog(@"UIButton Class");
UIButton *btn = view;
}
}
UIButtonは動作しますが、isKindOfClass:[EFButtonクラス]の状態では来ません。私が間違っていること、またはそれをどのように行う必要があるかを教えてください。