1

正常にロードされ、正常に表示され、すべてが正常に実行される UIScrollview があります。次に、別のビュー コントローラーをプッシュし、VC2 と呼びます。これも問題なく動作します。VC2 から UIScrollview に戻るためにポップすると、ここに奇妙な動作があります... UIScrollview が戻ってくると、上から最初の (推測している) 300 ピクセルが切り取られます。ページをプルダウンしてもコンテンツは表示されますが、明らかにうまくいきません。誰にも考えはありますか?

コードは次のとおりです。

これはScrollViewを作成しています:

-(IBAction)startNewSearch:(id)sender
{
NewSearch *VCscrollView = [[NewSearch alloc] init];
[[self navigationController] pushViewController:VCscrollView animated:YES];
}

ScrollView

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
    // Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
scrollView.contentSize = CGSizeMake(320, 890);
[scrollView setContentOffset:CGPointMake(0, 0) animated:NO];
[scrollView flashScrollIndicators];
}

-(void)viewWillAppear:(BOOL)animated
{
scrollView.frame = CGRectMake(0, 0, 320, 890);
}

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

ScrollView 内から VC2 を呼び出す IBAction:

-(IBAction)previewSearch:(id)sender
{   
VCcontactServer *VC2 = [[VCcontactServer alloc] init];
[[self navigationController] pushViewController:VC2 animated:YES];
}
4

1 に答える 1

1

正解の功績は Andrey Soloviev の功績によるものですが、残念ながら彼は私に彼の功績を称えるために投稿しませんでした。コードの追加:

-(void)viewWillAppear:(BOOL)animated
{
scrollView.frame = CGRectMake(0, 0, 320, 890);
}

説明どおりに問題を修正しました。問題の根本はもう少し複雑で、私の質問の範囲外でした。

于 2012-11-20T15:40:52.050 に答える