0

我有两个 ViewController

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

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 中的所有 UIButtons 等现在都被移动了,我猜,向下移动了 20 个像素。

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

4

1 回答 1

0

我有类似的问题,但父视图向上移动了 20 像素。

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

于 2013-07-11T14:05:42.347 回答