にUIView
ロードされており、ロードViewController
後に変更を加えたい (たとえば、それをクリックしてUIView
テキストの色を変更した場合)
@interface CategoryMenu : UIView
{
UIImageView *img;
UIButton *disclosureBtn;
UIButton *actionView;
UILabel *titleLabel;
}
@property (nonatomic,retain) IBOutlet UIImageView *img;
@property (nonatomic,retain) IBOutlet UIButton *disclosureBtn;
@property (nonatomic,retain) IBOutlet UIButton *actionView;
@property (nonatomic,retain) IBOutlet UILabel *titleLabel;
このようにして、必要な場所にこれをロードしUIView
ましUIViewController's
た。
-(void)showSubviews
{
int x = 0;
for (int i = 0; i < array.count ; i++)
{
NSArray* nibViews = [[NSBundle mainBundle] loadNibNamed:@"CustomMenu" owner:self options:nil];
CategoryMenu* tempUserView = [nibViews objectAtIndex:0];
tempUserView.userInteractionEnabled = YES;
[tempUserView setFrame:CGRectMake(0, x, 280, 50)];
x+=60;
tempUserView.tag = i;
tempUserView.titleLabel.text = [array objectAtIndex:i];
[tempUserView.actionView addTarget:self action:@selector(ExtendedCollapsed:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:tempUserView];
}
を押すとUIView
、アクション自体に加えて、テキストの色を変更したいと思いUILabel
ます。
-(void)ExtendedCollapsed:(id)sender
{
NSLog(@"[self.view subviews] = %@",[self.view subviews]);
UIView *view1 = (UIView *)sender;
for(UIView *view in [self.view subviews])
{
NSLog(@"view = %@ \n ", view);
if([view isKindOfClass:[CategoryMenu class]])
{
if (view.tag == view1.tag)
{
NSLog(@"We find the view !!!!");
CategoryMenu* tempUserView = (CategoryMenu*)view1;
NSLog(@"tempUserView = %@ \n ", tempUserView);
tempUserView.titleLabel.text = @"Text Changed";
tempUserView.titleLabel.textColor = [UIColor whiteColor];
NSLog(@"tempUserView.titleLabel.text = %@",tempUserView.titleLabel.text);
break;
}
}
else
{
NSLog(@"view is not a button");
}
}
}
UIViews
以前にロードされたものには何の変化も見られません。
誰かアドバイスをくれませんか?ありがとう