2010-09-17 17 views
0

我創建了通用應用程序,因爲我使用UIModalPresentationFull在iPad中顯示MFMailComposerSheet,這有助於在ipad橫向視圖中顯示MailComposer視圖的全屏。當我在ipad模擬器中運行應用程序時,我工作得很好。如果我將它設置爲iPhone模擬器3.0或3.1.3它顯示錯誤,如「錯誤:'UIModalPresentationFullScreen'未聲明(首次在此功能中使用)」當我評論它並在iPhone模擬器運行它的工作原理是什麼對於這個錯誤或者,否則是任何方法取代了「UIModalPresentationFull」在ipad和iphone中都能工作?UIModalPresentationFullScreen在UniversalApplication中給出錯誤

感謝和問候 Venkat

回答

0

UIModalPresentationFullScreen僅在3.2(及以上)SDK可用,所以你不能用SDK低於編譯。

但是,您不需要一個通用應用程序 - 您可以根據要運行的最高SDK編譯該應用程序,然後必須在運行時檢查您正在使用的方法/類是否可用。您在您的版本設置中設置此項:基本SDK應設置爲您使用的最高SDK(可能爲iPad 3.2)和iPhone操作系統部署目標應設置爲3.0 - 您的代碼最低的SDK跑。

你應該這樣每次做您使用的代碼3.2只有一點:

if ([controller respondsToSelector:@selector(setModalPresentationStyle:)]) 
    [controller setModalPresentationStyle:UIModalPresentationFullScreen]; 

然後,即使您已對3.2 SDK編譯的,當你在較低的SDK的設備上運行它,這個方法將不會運行。

我在一個仍然有3.0 SDK的iphone上測試它。我不確切地知道如何在模擬器中測試低SDK的問題。

+0

MR deanWombourne在這裏我的代碼我不知道如何實現上面的代碼請。 「MFMailComposeViewController *挑選器= [[MFMailComposeViewController的alloc] INIT]; \t picker.mailComposeDelegate =自我; 的NSString * Emailsubject的= NSLocalizedString(@」 EMAIL_SUBJECT」,@ 「」); \t [拾取器SETSUBJECT:Emailsubject的]; \t的NSString * emailBody = NSLocalizedString(@ 「EMAIL_BODY」,@ 「」); \t [拾取器setMessageBody:emailBody isHTML:YES]; \t \t = picker.modalPresentationStyle UIModalPresentationFullScreen; \t [自我presentModalViewController:拾取器動畫:YES]; \t picker.navigationBar.tintColor = UIColorFromRGB(0x003399); \t [picker release]; – venkat 2010-09-20 06:19:28

+0

對不起,我沒有回覆,我一直在度假!你有沒有得到它的工作? – deanWombourne 2010-09-29 16:13:20

-1
enter code here 

使用條件編譯塊中,我們可以隔離iPhone和iPad

過程

「#如果__IPHONE_OS_VERSION_MAX_ALLOWED> = 30200」

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) 
{ 
    // The device is an iPad running iPhone 3.2 or later. 
    if ([picker respondsToSelector:@selector(setModalPresentationStyle:)]) 
    { 
     //picker.modalPresentationStyle = UIModalPresentationFullScreen; 
     [picker setModalPresentationStyle:UIModalPresentationFullScreen]; 

    } 
} 

「#ENDIF」

請刪除引用和使用,如果和其他部分太...(即)條件彙編塊