好的,我周六问了这个问题,但我更新了更详细的问题。我有的问题是这个。当我运行我的应用程序时,主视图看起来很好,就像它想象的那样。但是,当我单击按钮转到下一个视图时,该视图向上移动大约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,这可以解决我曾经尝试过的问题,但我也找到了一种很好的方法。
提前感谢您对此问题的任何帮助..
答案 0 :(得分:0)
调整与状态栏有关的那些视图的框架。
但是,我不会依赖应用程序委托对象来处理多个视图。有一个根视图控制器来处理这些视图。
答案 1 :(得分:0)
我也遇到了转移视图的问题,并解决了以下问题。以下代码段从viewController切换到msgViewController。
打开mainWindow.xib并从库中添加UIViewController对象。将其类更改为处理指定viewController的类,然后单击。转到属性检查器的属性部分,为Controller设置相应的笔尖名称,然后保存并退出IB。
代码变为
-(void) flipToBack
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:window cache:YES];
[viewController.view removeFromSuperview];
[tabBarController.view removeFromSuperview];
[self.window addSubview:[msgViewController view]];
[UIView commitAnimations];
}
希望这可以帮助你!!
如果确实如此,请进行沟通。