MFMessageComposeViewController在4英寸屏幕上不全屏

时间:2013-03-13 08:20:59

标签: ios6 sms

我正在制作iPhone应用程序,在这个应用程序中,用户可以发送短信。 在我的iPhone 4上我的屏幕很完美,但在我的iPhone 5上我得到一个空白框。

仅限iPhone。 iOS 6x

屏幕截图(iphone5):http://i.stack.imgur.com/ZOqu1.png

enter image description here

#import "smsview.h"

@interface smsview ()

@end

@implementation smsview

- (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result
{
    [self dismissModalViewControllerAnimated:YES];

    if (result == MessageComposeResultCancelled)
        NSLog(@"Message cancelled");
    else if (result == MessageComposeResultSent)
        NSLog(@"Message sent");
    else
        NSLog(@"Message failed");
}

- (void)sendSMS:(NSString *)bodyOfMessage recipientList:(NSArray *)recipients
{
    MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
    if([MFMessageComposeViewController canSendText])
    {
        controller.body = bodyOfMessage;
        controller.recipients = recipients;
        controller.messageComposeDelegate = self;
        [self presentModalViewController:controller animated:YES];
    }
}


-(IBAction)Text:(id)sender
{
    {
        [self sendSMS:@"" recipientList:[NSArray arrayWithObjects:@"+1-234-567-8910", nil]];
    }
}


- (void)viewDidLoad
{
    [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

@end

1 个答案:

答案 0 :(得分:2)

如果你没有成功,请按照以下步骤操作。

  1. 如果不从here下载,您是否使用最新版本的Xcode。

  2. 您可以使用自动布局功能并使用iPhone 5屏幕分辨率创建设计,它将适用于4“和3.5”设备,但在这种情况下,您应该对布局管理器有足够的了解

  3. 为您的应用设置4英寸的启动图像。这就是你获得1136像素屏幕高度的方法(没有它,你将得到960像素,顶部和底部有黑色边距),为了使你的应用适应新的更高屏幕,你要做的第一件事就是将发布图像更改为: Default-568h@2x.png。它的大小应该是1136x640(HxW)。是的,在新屏幕尺寸中使用默认图像是让您的应用程序占据整个iPhone 5新屏幕的关键..

  4. 如果您已正确设置自动调整大小的蒙版,希望一切正常。

  5. 如果没有,请使用正确的自动调整大小的蒙版调整视图布局,或者如果您只想支持iOS 6,请查看自动布局。

  6. 如果你需要特别针对较大的屏幕做一些事情,那么看起来你必须检查[[UIScreen mainScreen] bounds](或者applicationFrame的高度),但是如果是的话你需要考虑状态栏的高度因为似乎没有特定的API。

  7. 例如:

    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    if (screenBounds.size.height == 568) {
        //iPhone 4 specific
    } else {
        //iPhone 5 specific
    }
    

    希望这能解决你的问题。