- (IBAction)add {
UIImageView *must = [UIImageView alloc];
[must setImage:[UIImage imageNamed:@"themustache.png"]];
must.center = CGPointMake(0, 0);
[self.view addSubview:must];
[must bringSubviewToFront:self.view];
}
當我按下一個按鈕,它應該添加鬍鬚,但它不會添加子視圖不起作用
check [this](http://stackoverflow.com/questions/3994174/how-to-add-a-uiview-as-a-subview-of-uiviewcontrollr-when-a-button-clicked -on-uivi)。 希望這有助於。 – viral
並在你的函數中添加NSLog(),看它是否被調用(請參閱登錄控制檯。)試試吧。 – viral
是的,它叫做 – user894725