我將UIButton上的UIImageView設置爲圖像,但是如果正在加載,則隱藏該圖像。然後,我將UIActivityIndicatorView添加到圖像視圖的位置。但是,當我觸摸標題按鈕時,圖像視圖突然出現而不更改隱藏屬性。它與我添加到按鈕的選擇器/目標沒有任何關係,因爲我已經評論了這一點。爲什麼UIButton上的UIImageView再次出現在觸摸上?
按鈕創建:
[button setTitleColor:[UIColor grayColor] forState:UIControlStateNormal];
[button setTitleColor:[UIColor blueColor] forState:UIControlStateSelected];
[button setTitle:buttonTitles[i] forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:buttonTitles[i]] forState:UIControlStateNormal];
添加指示燈查看在按鈕類別:
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
indicator.frame = self.imageView.frame;
[self addSubview:indicator];
self.imageView.hidden = YES;
更改你的問題的稱號,這是不是一個UIImageView只UIImage的 –
不知道你的意思......上的UIButton的ImageView的屬性是一個UIImageView – mergesort
是,但圖像是你需要消失的東西。 嘗試此: 'UIActivityIndicatorView *指示符= [[UIActivityIndicatorView的alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray]; [indicator startAnimating]; indicator.frame = self.imageView.frame; [self addSubview:indicator]; [button setImage:nil forState:UIControlStateNormal];' –