MFMessageComposeViewController在4英寸屏幕上不是全屏幕

问题描述:

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

iPhone的iOS 6倍

Screenhot(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. 如果不是从here下载,是否使用最新版本的Xcode?

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

  3. 为您的应用程序设置4英寸启动图像。这就是你如何获得1136像素的屏幕高度(没有它,你会得到960像素,在顶部和底部有黑色边距)。为了使你的应用适应新的更高屏幕,首先要做的是将启动图像更改为: [email protected]。它的大小应该是1136x640(HxW)。是的,在新的屏幕尺寸的默认图像是让你的应用程序采取全新的iPhone 5的屏幕的关键..

  4. 希望一切都应该工作,如果你已经正确设置自动调整大小的面具。

  5. 如果您没有,请使用适当的自动调整大小遮罩来调整视图布局,或者如果您只想支持iOS 6,请查看“自动布局”。

  6. 如果有什么事情你需要为更大的屏幕专门做,那么它看起来像你必须检查高度[[UIScreen mainScreen] bounds](或applicationFrame,但你需要考虑状态栏高度,如果它存在),因为看起来好像对此没有具体的API。

例如:

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

希望这能解决你的问题。

+0

不工作:( 我的问题是,只有当我发送一个应用程序内的短信。 – 2013-03-13 10:15:49

+0

尝试一件事,然后,去的MainWindow.xib,选择主窗口和属性检查器(右标签第四选项),选择大小,并将其设置为自由形式。现在让我们来回答一下。 – Krishanbhag 2013-03-13 10:23:45

+0

只有smsview是问题。 其他视图可以在我的iPhone 5上正常工作 – 2013-03-13 10:36:10