2013-03-13 98 views
0

我正在製作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 

回答

2

如果您失敗,請執行以下步驟。

  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