我对 xcode 还很陌生,并且遇到了滚动视图的问题。滚动视图工作正常......但是当使用情节提要和推送组合时我遇到了问题。第一次查看滚动视图时它工作正常,但是当您推送到新页面然后返回故事板时滚动视图不再滚动。我认为这与 didload 有关,也许我应该使用 willappear?代码如下。我认为我需要以某种方式更改此代码,以便每次返回此故事板时都会重新加载故事板...有其他人遇到此问题或建议如何解决吗?
//
// PrintViewController.m
//
//
#import "PrintViewController.h"
@interface PrintViewController ()
@end
@implementation PrintViewController
@synthesize PrintScroller, rememberContentOffset;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[PrintScroller setScrollEnabled:YES];
// Do any additional setup after loading the view.
}
- (void) viewDidAppear:(BOOL)animated {
[PrintScroller setContentSize:CGSizeMake(300, 595)];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
self.PrintScroller.contentOffset = CGPointMake(0, 0);
}
- (void)viewWillDisappear:(BOOL)animated {
self.rememberContentOffset = self.PrintScroller.contentOffset;
[super viewWillDisappear:animated];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.PrintScroller.contentOffset = CGPointMake(0, self.rememberContentOffset.y);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end