【发布时间】:2011-02-26 20:34:06
【问题描述】:
好的,我昨天问过这个问题,但我更新了它,更详细地说明了我遇到的问题。我遇到的问题是这个。当我运行我的应用程序时,主视图看起来很好,就像它假设的那样。但是,当我单击按钮转到下一个视图时,该视图向上移动了大约 20 像素。当我回到主屏幕时,它会向上移动。
我的应用程序看起来像它的唯一一次是当我第一次加载它时,一旦我单击一个按钮并开始更改视图,我离开主视图后的每个视图第一次向上移动 20 像素,甚至当我回到主视图时。当我从 xcode 3.2 升级到 xcode 4.0 beta 时,我开始遇到这个问题。我发现了一种切换视图的方法,它不会使视图向上移动,但是,我对这种方式有疑问。我让用户在 view1 上输入数据,单击按钮时它会切换到 view2 并将该数据从 1 发送到 2。使用 switchview 方法显示我的视图,因为它们被认为是我不想传输到 view2 的数据。使用 switchview 方法可以将数据从 1 传输到 2,它可以将视图向上移动 20 个像素。以下是我使用的示例。
-- 以这种方式使用 xcode 4 会导致我的视图向上移动 20 像素,而 xcode 3.25 效果很好,没有问题,它将数据从 view1 传输到 view2。
- (IBAction)calculate:(id)sender {
MaleResultsController *maleResults = [[MaleResultsController alloc] initWithNibName:@"MaleResultsController" bundle:nil];
[UIView beginAnimations:@"flipping view" context:nil];
[UIView setAnimationDuration:.75];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown
forView:self.view cache:YES];
[self.view addSubview:maleResults.view];
maleResults.displayAge.text = ageInput.text;
maleResults.displayHeight.text = heightInput.text;
maleResults.displayWeight.text = weightInput.text;
NSString *minWeightString = [[NSString alloc] initWithFormat:@"%.0f", [self getMinWeight]];
maleResults.displayMinWeight.text = minWeightString;
[minWeightString release];
NSString *maxWeightString = [[NSString alloc] initWithFormat:@"%.0f", [self getMaxWeight]];
maleResults.displayMaxWeight.text = maxWeightString;
[maxWeightString release];
NSString *maxBodyFatString = [[NSString alloc] initWithFormat:@"%.0f", [self getMaxBodyFatPercentage]];
maleResults.displayMaxBodyFatPercentage.text = maxBodyFatString;
[maxBodyFatString release];
NSString *bodyFatString = [[NSString alloc] initWithFormat:@"%.0f", [self getBodyFatPercentage]];
maleResults.displayBodyFat.text = bodyFatString;
[bodyFatString release];
NSString *abdomenAvgString = [[NSString alloc] initWithFormat:@"%.2f", [self getAbdomenAvg]];
maleResults.abdomenAvg.text = abdomenAvgString;
[abdomenAvgString release];
NSString *neckAvgString = [[NSString alloc] initWithFormat:@"%.2f", [self getNeckAvg]];
maleResults.neckAvg.text = neckAvgString;
[neckAvgString release];
NSString *abNeckFactorString = [[NSString alloc] initWithFormat:@"%.2f", [self getAbNeckFactor]];
maleResults.abdomenNeckFactor.text = abNeckFactorString;
[abNeckFactorString release];
//
// [self.navigationController pushViewController:maleResults animated:YES];
[UIView commitAnimations];
}
-- 对于 xcode 4,此方法可以正确切换视图,但不会将 view1 上的文本字段输入传输到 view2 上的标签输出..
- (IBAction)calculate:(id)sender {
MaleBFCResults *maleBFCresults = [[MaleBFCResults alloc] initWithNibName:@"MaleBFCResults" bundle:nil];
MaleBFCdata *maleBFCData = [[MaleBFCdata alloc] init];
maleBFCresults.maleData = maleBFCData;
maleBFCresults.displayAge = ageInput.text;
maleBFCresults.displayHeight = heightInput.text;
maleBFCresults.displayWeight = weightInput.text;
maleBFCresults.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController:maleBFCresults animated:YES];
[maleBFCresults release];
}
几周以来,我一直在寻找解决此问题的方法,但找不到任何帮助。我还没有把我所有的论坛和计算放在这个新的地方,因为我想在我花时间写出所有计算代码之前确保 UI 正常运行。我喜欢“modalTransitionStyle”给我的过渡,而不是“setAnimationTransition”。这很好,因为它可以正常切换视图,我只是无法让它将数据从 view1 传输到 view2。
我确定如果我必须这样做,我总是可以恢复到以前版本的 xcode,但我尽量不必这样做,如果有人遇到类似问题并且有解决方案,我将不胜感激。甚至可能有一种不同的方法可以将数据从 view1 发送到 view2,我还没有尝试过,但我也没有找到一个好方法。
提前感谢您对此问题的任何帮助..
【问题讨论】:
标签: objective-c cocoa xcode ios4