2015-04-02 74 views
0

我用戶界面生成器來定位疊加UIButton和UIImageView。 在代碼中,更改按鈕標籤,如果存在圖像UIButton標籤不會出現在UIImageView上

在example.h文件

@property (strong, nonatomic) IBOutlet UIButton *takePicture; 
@property (strong, nonatomic) IBOutlet UIImageView *image; 

在Example.m

[self.image setImage:aPhoto]; 
(...) 
NSString *pictureButtonTitle  = [email protected]"Changer la photo":@"Ajouter une photo"; 
(...) 
[self.takePicture setTitle:pictureButtonTitle forState:UIControlStateNormal]; 

我使用此代碼爲一個視圖,我看「當myCondition爲true時,在我的圖片上正確更改圖片「。 但在另一種觀點,沒有出現!爲什麼?

回答

1

你既可以做到在界面生成器 - 爲你做,或做在您的viewDidLoad方法:

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    [self.view bringSubviewToFront:self.button]; 
} 

排號網點在IB,你也意味着較低的對象將是其他人的頂部......當按鈕放置在屏幕截圖中所示的所有其他對象的下方時,該按鈕將位於「頂部」/頂部。

如果你想以不同的方式安排的網點,你可以用這些方法,以及:

[self.view insertSubview:self.button aboveSubview:self.imageView]; 

或者:

[self.view insertSubview:self.imageView belowSubview:self.button]; 
+1

謝謝你,我喜歡你的方式! – 2015-04-03 12:07:56

0

好吧,我發現:在界面生成器,它似乎是爲了你把你的對象如果放置的UIButton之前的UIImageView重要

,它工作得很好。

enter image description here

我看到標籤

enter image description here

但是,如果你正好相反:按鈕是像下。

enter image description here

和標籤不顯示

enter image description here

我仍然不知道這是否是重新安排這些項目的唯一途徑?