2014-03-04 137 views
0

我正在使用一個xib文件來處理我的舊項目。我有一個按鈕,將UIImageview的位置更改爲0,0,但它不起作用,標籤停留在初始位置。當我用完全相同的代碼創建新項目時,它包含一個mainStoryboard.Storyboard,它工作正常。我想這與xib文件和文件所有者有關。爲什麼我無法訪問UIImageview.center?

#import "ViewController.h" 

@interface ViewController() 

@end 

@implementation ViewController 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 
    // Do any additional setup after loading the view, typically from a nib. 
} 

- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

- (IBAction)Action1:(id)sender { 
    imageview.center = CGPointMake(0, 0); 
} 
+0

你說'UIImageView'的中心,但我只看到一個'UILabel'的中心被稱爲...? – JMarsh

+0

label1是imageView?正如@JMarsh已經問過,UIImageView在哪裏?請發佈適當的問題。 – Pawan

+0

對不起,我編輯它。我發佈了錯誤的代碼,但它仍然與標籤和所有其他UI元素相同。 ;) – Freddy

回答

0

如果您使用的是auto layout,更改框架可能沒有任何作用。

相反,您需要更改視圖上的constraints

您可以在Ray Wenderlich的網站here或視頻教程here上找到關於自動佈局的書面教程。

相關問題