Cocoa touch 故事板和xib在视图外观过程中的不一致

Cocoa touch 故事板和xib在视图外观过程中的不一致,cocoa-touch,storyboard,Cocoa Touch,Storyboard,我不明白在视图外观链期间询问UIView的框架和/或与故事板与传统xib相关的差异何时是安全的 我在Xcode 4.5.1中创建了两个不同的、非常简单的单UIViewController项目;在第一个示例中,我使用了带有xib的标准单视图模板,在第二个示例中,我使用了故事板。ViewController.m(两个项目的源代码相同)如下所示。在IB中,我拖入了一个UIScrollView,并将其适当地连接到我的控制器插座 正如您在源代码中所注意到的,我在视图外观链的不同点注销了滚动视图的框架。我不

我不明白在视图外观链期间询问
UIView
的框架和/或与故事板与传统xib相关的差异何时是安全的

我在Xcode 4.5.1中创建了两个不同的、非常简单的单
UIViewController
项目;在第一个示例中,我使用了带有xib的标准单视图模板,在第二个示例中,我使用了故事板。
ViewController.m
(两个项目的源代码相同)如下所示。在IB中,我拖入了一个
UIScrollView
,并将其适当地连接到我的控制器插座

正如您在源代码中所注意到的,我在视图外观链的不同点注销了滚动视图的框架。我不明白它们为什么不同,以及/或者我何时可以安全地查询UIScrollView框架,因为它位于
viewDidLoad
中的(0,0)

ViewController.m xib的结果 故事板的结果
答案是
viewdilayoutsubviews
。但愿我20分钟前见过你。下面是更新的源代码和日志输出

ViewController.m 故事板输出
#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"viewDidLoad scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);
}
- (void)viewWillLayoutSubviews {
    NSLog(@"viewWillLayoutSubviews scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);    
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);

}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"viewDidAppear scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);
}
@end
2012-10-23 11:49:48.316 ScrollTest[83262:c07] viewDidLoad scrollView.frame = (320,548)
2012-10-23 11:49:48.318 ScrollTest[83262:c07] viewWillAppear scrollView.frame = (320,548)
2012-10-23 11:49:48.321 ScrollTest[83262:c07] viewWillLayoutSubviews scrollView.frame = (320,548)
2012-10-23 11:49:48.328 ScrollTest[83262:c07] viewDidAppear scrollView.frame = (320,460)
2012-10-23 11:49:58.762 ScrollTestStoryboard[83308:c07] viewDidLoad scrollView.frame = (  0,  0)
2012-10-23 11:49:58.763 ScrollTestStoryboard[83308:c07] viewWillAppear scrollView.frame = (  0,  0)
2012-10-23 11:49:58.765 ScrollTestStoryboard[83308:c07] viewWillLayoutSubviews scrollView.frame = (  0,  0)
2012-10-23 11:49:58.772 ScrollTestStoryboard[83308:c07] viewDidAppear scrollView.frame = (320,460)
#import "ViewController.h"

@interface ViewController ()
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];
    NSLog(@"viewDidLoad scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);
}
- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    NSLog(@"viewWillAppear scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);

}
- (void)viewWillLayoutSubviews {
    NSLog(@"viewWillLayoutSubviews scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);
}
- (void)viewDidLayoutSubviews {
    NSLog(@"viewDidLayoutSubviews scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);
}
- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    NSLog(@"viewDidAppear scrollView.frame = (%3.0f,%3.0f)",self.scrollView.frame.size.width,self.scrollView.frame.size.height);
}
@end
2012-10-23 12:12:35.597 ScrollTestStoryboard[87593:c07] viewDidLoad scrollView.frame = (  0,  0)
2012-10-23 12:12:35.599 ScrollTestStoryboard[87593:c07] viewWillAppear scrollView.frame = (  0,  0)
2012-10-23 12:12:35.601 ScrollTestStoryboard[87593:c07] viewWillLayoutSubviews scrollView.frame = (  0,  0)
2012-10-23 12:12:35.602 ScrollTestStoryboard[87593:c07] viewDidLayoutSubviews scrollView.frame = (320,460)
2012-10-23 12:12:35.609 ScrollTestStoryboard[87593:c07] viewDidAppear scrollView.frame = (320,460)