有一个类似的,但悬而未决的问题 bound and frame for a UIButton的UIButton - 框架和边界零 - 页基于应用程序
我使用带有自动布局和故事板“页基于应用程序模板”
我能通过使基于标准页面的应用向故事板添加按钮并引用它来重现此问题
viewDidAppear DataViewController.m
- (void)viewDidAppear:(BOOL)animated
{
NSLog(@"View did appear");
NSLog(@"self.myButton.bounds = %@",NSStringFromCGRect(self.myButton.bounds));
NSLog(@"self.myButton.frame = %@",NSStringFromCGRect(self.myButton.frame));
NSLog(@"self.myButton = %@",self.myButton);
}
输出
2013年5月14日19:37:45.954 FrameTest4 [10777:C07]查看确实出现 2013年5月14日19:37:45.966 FrameTest4 [10777:C07]自我。 myButton.bounds = {{0,0},{0,0}} self.myButton.frame = {{0,0},{0,0,0}} 2013-05-14 19:37:45.968 FrameTest4 [10777:c07] 0}} 2013年5月14日19:37:45.970 FrameTest4 [10777:C07] self.myButton =>
头文件
#import <UIKit/UIKit.h>
@interface DataViewController : UIViewController
@property (strong, nonatomic) IBOutlet UILabel *dataLabel;
@property (strong, nonatomic) id dataObject;
@property (weak, nonatomic) IBOutlet UIButton *myButton;
当我运行相同的代码与单个视图应用程序自动布局和故事板它工作正常。
我需要这些信息的原因是我需要运行结束于按钮的动画。 谢谢 Ryan
从您的日志中不清楚:您的按钮是否为零? – Mundi 2013-05-14 19:51:19
按钮不是零,只是框架和边界。 – 2013-05-15 05:40:54