OK i asked this yesturday but i updated it with more detail as to the problems im having. The problem im having is this. When i run my app, the main view looks fine, just as it is suppose to. But, when i click a button to go to the next view, that view is shifted up about 20pixels. When i goback to the main screen it is shifted up the same.
The only time that my app looks like it is suppose to is when i first load it, once i click a button and start changing views, every view after i leave the mainview that first time is shifted up 20 pixels, even the mainview when i go back to it. I started having this issue when i upgraded from xcode 3.2 to xcode 4.0 beta. There is one way i have found to switchviews that doesnt make the views shift up BUT, i have an issue with this way. I have users input data on view1, on button click it switches to view2 and sends that data from 1 to 2. Using the switchview method that shows my views as they are suppose to be my data dont want to transfer to view2. Using the switchview method that gives me the data transfer from 1 to 2 that i need, it shifts the views up by 20 pixels. below are the examples of what im using.
-- with xcode 4 this way causes my views to shift up 20 pixels where as xcode 3.25 it worked great, had no issues and it transfered the data from view1 to 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];
}
-- with xcode 4 this method works to switch views correctly but doesnt transfer textfield input on view1 to label output on 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];
}
I have been searching for ways to fix this issue for a couple weeks now, and havnt been able to find anything to help. I havnt put all my forumlas and calculations into place yet on this new one because i want to make sure that the UI is functioning properly before i spend the time writing out all the code for the calculations. I like the transitions that "modalTransitionStyle" gives me over the "setAnimationTransition". Which is good because it works properly to switch views i just cant get it to transfer data from view1 to view2.
Im sure if i had to i could always revert back to the previous version of xcode but im trying not to have to do have to do that, if anyone has had a开发者_如何学Go similar issue and has a solution i would really appreciate it. there may even be a different way to send data from view1 to view2 that would work that i havnt tried yet, but i havnt found a good way to do that either.
thanks in advance for any help with this issue..
I also faced the same problem of shifting view adn resolved it as below. The following code snippet switches from viewController to msgViewController.
Open the mainWindow.xib and add the UIViewController Object from the Library. Change its class to your Class that handles the specified viewController and then comes the click. Go to the properties section of the Attribute Inspector and set the respective Nib Name for the Controller and now save and exit the IB.
And the code changes to
-(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];
}
Hope this helps you!!
If it does please communicate.
Adjust the frame of those views regarding to the status bar.
However, I wouldn't rely on the application delegate object to handle multiple views. Have a root view controller which takes care of those views.
精彩评论