解雇MFMailComposeViewController会导致向上移位

时间:2014-03-16 20:16:39

标签: ios ios7 mfmailcomposeviewcontroller

我在解雇MFMailComposeViewController并返回iOS7中的移动屏幕时遇到了问题。下面的方法适用于iOS6,不会将屏幕向上移动约25-30。将我的[[UIScreen mainScreen] applicationFrame]]改为使用自动调整大小并不是按照另一个向下移动问题的建议修复我的问题。

#import "RootViewController.h"

@implementation RootViewController

- (void)loadView {

    self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]] autorelease];
    self.view.backgroundColor = [UIColor whiteColor];


navBar = [[UINavigationBar alloc] init];
navBar.frame = CGRectMake(0, 0, self.view.frame.size.width, 44);
    UINavigationItem *navItem = [[[UINavigationItem alloc] initWithTitle:@"iShift"] autorelease];

    UIBarButtonItem *mail = [[[UIBarButtonItem alloc] initWithTitle:@"Email" style:UIBarButtonItemStylePlain target:self action:@selector(sendMail)] autorelease];
navItem.rightBarButtonItem = mail;
navBar.barStyle = UIBarStyleDefault;
navBar.items = [NSArray arrayWithObject:navItem];
 [self.view addSubview:navBar];


}


- (void)sendMail {

    MFMailComposeViewController *compose = [[MFMailComposeViewController alloc] init];
compose.mailComposeDelegate = self;

    if ([MFMailComposeViewController canSendMail]){
NSArray *toRecipients = [NSArray arrayWithObjects:@"sample@gmail.com", nil];
[compose setToRecipients:toRecipients];
[compose setSubject:@"Test Email"];
[compose setMessageBody:@"Device: \niOS Version: \nProblem: \n\nSuggestions: \n" isHTML:NO];

[self presentModalViewController:compose animated:YES];

}

[compose release];

}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {

[self dismissModalViewControllerAnimated:YES];

}
@end

1 个答案:

答案 0 :(得分:0)

我已经设法通过将[[UIScreen mainScreen] applicationFrame]]更改为[[UIScreen mainScreen] bounds]]并将导航栏位置填充20磅来解决此问题,导致以下代码。如果有人可以指出这个问题,我可以接受建议。 (使用tableview,它的位置也被填充20分)

#import "RootViewController.h"

@implementation RootViewController

- (void)loadView {

self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
self.view.backgroundColor = [UIColor whiteColor];


navBar = [[UINavigationBar alloc] init];
navBar.frame = CGRectMake(0, 20, self.view.frame.size.width, 44);
UINavigationItem *navItem = [[[UINavigationItem alloc] initWithTitle:@"iShift"] autorelease];

UIBarButtonItem *mail = [[[UIBarButtonItem alloc] initWithTitle:@"Email" style:UIBarButtonItemStylePlain target:self action:@selector(sendMail)] autorelease];
navItem.rightBarButtonItem = mail;
navBar.barStyle = UIBarStyleDefault;
navBar.items = [NSArray arrayWithObject:navItem];
[self.view addSubview:navBar];


}


- (void)sendMail {

MFMailComposeViewController *compose = [[MFMailComposeViewController alloc] init];
compose.mailComposeDelegate = self;

if ([MFMailComposeViewController canSendMail]){
NSArray *toRecipients = [NSArray arrayWithObjects:@"sample@gmail.com", nil];
[compose setToRecipients:toRecipients];
[compose setSubject:@"Test Email"];
[compose setMessageBody:@"Device: \niOS Version: \nProblem: \n\nSuggestions: \n" isHTML:NO];

[self presentModalViewController:compose animated:YES];

}

[compose release];

}

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {

[self dismissModalViewControllerAnimated:YES];

}
@end
相关问题