0
我有兩個視圖控制器目標C dismissViewControllerAnimated移動最終視聽下來
VC1增加VC2作爲一個子視圖itselfe。
VC2有UIButton
,它調用的後續代碼:在VC2所有UIButtons等
-(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];}
一切工作正常,但:
if([MFMailComposeViewController canSendMail]) {
MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
mailer.mailComposeDelegate = self;
[mailer setSubject:[NSString stringWithFormat:@"BlaBla."]];
NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", 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];
}
郵件完成後,它調用以下現在被移動了,我想是20個像素。
我不能想象爲什麼,我想問題是我添加一個ViewController作爲子視圖到另一個ViewController並調用那裏的方法。但我不能想象如何解決這個問題。
在解除郵件撰寫視圖控制器之前或之後是否移動了所有按鈕?你如何將VC2作爲子視圖添加到VC1?你能發佈你的代碼嗎?您可能需要將VC2的幀設置爲等於VC1的邊界。 –