Objective C dismissViewControllerAnimated向下移动最后一个视图

时间:2013-05-27 11:13:12

标签: objective-c uiviewcontroller uibutton

我有两个ViewController

VC1将VC2作为子视图添加到itselfe。

VC2有一个UIButton,它正在调用以下代码:

if([MFMailComposeViewController canSendMail]) {

    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
    mailer.mailComposeDelegate = self;
    [mailer setSubject:[NSString stringWithFormat:@"BlaBla."]];

    NSArray *toRecipients = [NSArray arrayWithObjects:@"blabla@gmail.com", nil];
    [mailer setToRecipients:toRecipients];

    NSString *emailBody = [NSString stringWithFormat:@"Testtext1"];
    [mailer setMessageBody:emailBody isHTML:NO];

    [self presentViewController:mailer animated:YES completion:nil];      

}
else {
    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Fehler" message:@"Ihr Gerät unterstützt die gewünschte Funktion nicht" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
    [alert show];
}

邮件完成后,它会调用以下内容:

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error{
switch (result)
{
    case MFMailComposeResultCancelled:
    { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hinweis"
                                                      message:@"Vorgang abgebrochen, es wurde keine E-Mail versendet."
                                                     delegate:self
                                            cancelButtonTitle:@"Ok"
                                            otherButtonTitles: nil];

        [alert show];

    }

        break;
    case MFMailComposeResultSaved:
    { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hinweis"
                                                      message:@"Ihre E-Mail wurde gespeichert."
                                                     delegate:self
                                            cancelButtonTitle:@"Ok"
                                            otherButtonTitles: nil];

        [alert show];

    }

        break;
    case MFMailComposeResultSent:
    { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hinweis"
                                                      message:@"Ihre E-Mail wird versendet."
                                                     delegate:self
                                            cancelButtonTitle:@"Ok"
                                            otherButtonTitles: nil];

        [alert show];

    }

        break;
    case MFMailComposeResultFailed:
    { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hinweis"
                                                      message:@"Vorgang abgebrochen, die E-Mail konnte nicht gesendet werden."
                                                     delegate:self
                                            cancelButtonTitle:@"Ok"
                                            otherButtonTitles: nil];

        [alert show];
    }

        break;
    default:
    { UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Hinweis"
                                                      message:@"E-Mail wurde nicht gesendet."
                                                     delegate:self
                                            cancelButtonTitle:@"Ok"
                                            otherButtonTitles: nil];

        [alert show];

    }

        break;
}
[self dismissViewControllerAnimated:YES completion:nil];}

一切正常,但VC2中的所有UIButton等现在都被移动了,我想,它们会下降20个像素。

我不能想象为什么,我想问题是我将ViewController作为Subview添加到其他ViewController并在那里调用methode。但我无法想象如何解决这个问题。

1 个答案:

答案 0 :(得分:0)

我有类似的问题,但父视图被移动了20 px。

解决方案基于更改“想要全屏”。我必须将此值设置为YES,但不是所有子视图控制器。