由于在 iOS 5.1 上使用 Xcode 4.3 进行调试非常慢,因此在设备上启动/安装应用程序时,我使用启动速度更快的模拟器。(请参阅我关于此问题的问题https://stackoverflow.com/questions/11541288/xcode-4-3-with-ios5-1-pauses-about-10secs-when-debug-starts-simulator-starts-i)
所以我需要做的就是这样的:
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = delegate;
NSString *s = @"1234567";
picker.recipients =[NSArray arrayWithObject: s];
picker.body =smsTxt;
if (simulationMode) {
MessageComposeResult result = MessageComposeResultSent; <-----------
[delegate messageComposeViewController:picker didFinishWithResult: result];
} else
[delegate presentModalViewController:picker animated:YES];
现在的问题是,在 iOS 模拟器上执行时 MFMessageComposeViewController 不能被实例化并且总是产生 nil。
有没有办法在 iOS 模拟器上创建另一个对象 MyOwnMFMessageComposeViewController,它与 MFMessageComposeViewController 兼容并且可以像 MFMessageComposeViewController 一样以相同的方法传递?
像这样的东西:
MFMessageComposeViewController *picker = [[MFMessageComposeViewController alloc] init];
picker.messageComposeDelegate = delegate;
NSString *s = @"1234567";
picker.recipients =[NSArray arrayWithObject: s];
picker.body =smsTxt;
if (simulationMode) {
MyOwnMFMessageComposeViewController *mypicker = [[MFMessageComposeViewController alloc] init];
mypicker.messageComposeDelegate = delegate;
NSString *s = @"1234567";
mypicker.recipients =[NSArray arrayWithObject: s];
mypicker.body =smsTxt;
MessageComposeResult result = MessageComposeResultSent;
picker = (MFMessageComposeViewController) mypicker;
[delegate messageComposeViewController:picker didFinishWithResult: result];
} else
[delegate presentModalViewController:picker animated:YES];