2014-09-03 62 views
1

我试图让我的按钮在图像内移动到x = 160和y = 468如果图像的高度大于412但它不起作用。我试图解决这个自动布局,但它似乎非常困难,我有。任何人都可以帮助我或向我展示解决此问题的最佳方法吗?我的.m文件的定义新的帧起点x,y如果我的图像高度大于412

部分:

@interface welcomeViewController() 

@end 

@implementation welcomeViewController 

@synthesize imgWelcome; 
@synthesize btnPedir; 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [self btnLayout]; 

} 

- (void)btnLayout 
{ 
    if (imgWelcome.frame.size.height > 412) { 
     CGRect rect = self.btnPedir.frame; 
     rect.origin.x = 160; 
     rect.origin.y = 468; 
     self.btnPedir.frame = rect; 
    } 
} 

@end 

imgWelcome =图像的按钮是内部

btnPedir =按钮

+0

btnPedir在哪里/如何定义?代码执行之前它的框架是什么?你在屏幕上看到了什么? – pbasdf 2014-09-03 21:11:33

回答

0
  • (无效)btnLayout { 如果(imgWelcome.frame .size.height> 412)CGRect rect = self.btnPedir.frame; rect.origin.x = 160; rect.origin.y = 468; self.btnPedir.frame = rect; }}

这里你的按钮y位置从468开始,你没有提的是它的height.What我假设你的按钮帧是超出你的上海华帧。