MFMessageComposeViewController on Simulator - canSendText? - ios5

following situation: I want to send in app SMS. This is my code creating the MFMessageComposeViewController:
-(void) showMessageComposerWithText:(NSString*)messageText telNumber:(NSString*)telNumber composeDelegate:(id)delegate
{
MFMessageComposeViewController *controller = [[MFMessageComposeViewController alloc] init];
if([MFMessageComposeViewController canSendText])
{
controller.body = messageText;
controller.recipients = [NSArray arrayWithObject:telNumber];
controller.messageComposeDelegate = delegate;
[delegate presentModalViewController:controller animated:YES];
}
}
So I think this is straight forward. When testing in Simulator I get following exception: Application tried to push a nil view controller on target <MFMessageComposeViewController: 0x8a4e090>. I'm also wondering myself why [MFMessageComposeViewController canSendText] returns YES when running the app in the simulator.
When running on the device, everything is working correctly.
I couldn't find anything in the docs/web concerning this strange behavior.
I'm running Xcode 4.3 on OS 10.7.3, Deployment Target is iOS 5.0.
Thanks in advance,
tubtub

This problem occurs when you install Messages beta on OS X Lion.
Edit: It also occurs on Mountain Lion when there is an iMessage account configured and enabled. If the account is disabled, it works correctly (canSendText returns NO).
Tip: If you use controller.modalTransitionStyle = UIModalTransitionStylePartialCurl, you can go back in Simulator by clicking on the curled "page" in the upper left corner.

The simulator should always return NO from the canSendText, this isn't the case for the iOS 5.0 and 5.1 simulators. With Xcode 4.2 it crashed, on Xcode 4.3 it just pushes a nil view controller.

I'm seeing the same thing. I think it's a bug in the iOS 5 simulator with Xcode 4.3. canSendText correctly returns NO in the iOS 4.3 simulator. The same code works fine on the device.

With this configuration, canSendText returns correctly NO in the simulator (plus, a UIAlertView appears to say text messaging is not available):
Mountain Lion
Xcode 4.4,
iOS 5.1

Related

App crash when running on iPhone 4.3 simulator after calling initWithNibName

I have the following code associated with pressing a button:
- (IBAction)favorites
{
FavoritesActivityViewController *favorites = [[FavoritesActivityViewController alloc] initWithNibName:#"FavoritesActivityViewController" bundle:[NSBundle mainBundle]];
[self.view addSubview:favorites.view];
}
When I run it on my iOS device (v 6.1) it works fine but when running on the 4.3 simulator it crashes when getting to calling addSubView. I have noticed that it crashes for any method I call on self.view like setTag etc so I guess the problem is with the returned object from initWithNibName
Thanks,
Simon
Goto FavoritesActivityViewController xib file, select file inspector tab, set Deployment target to ios 4.3 and uncheck AutoLayout. AutoLayout allows you to set constraints on UI controls. It is intended for iOS 6 and above only. To support nib for below iOS 6 versions, you must uncheck AutoLayout.
FavoritesActivityViewController *favorites = [[FavoritesActivityViewController alloc]initWithNibName:#"FavoritesActivityViewController" bundle:nil];
[self.view addSubview:favorites.view];
Try this code...
Are you sure the file named "FavoritesActivityViewController.xib" is isexists and the property named "Class" of File's Owner is "FavoritesActivityViewController".

Old XIB is loaded every second time I load my app?

I have a very strange problem.
Sometimes when I launch my app (on iPhone device or in Xcode iOS 5.1 Simulator) I got an old version of the XIB I'm doing changes with. Anyone have any tip on what could be wrong?
Here is the code from where i launch the XIB:
MapKitDragAndDropViewController *spview = [[MapKitDragAndDropViewController alloc] initWithNibName:nil bundle:nil];
[self presentModalViewController:spview animated:YES];
Found the problem! I had two xib-files. One for iPhone and one for iPad version. Both had same name. removed one because the view suits both formats.
Did you try cleaning your project?? Also remove the app from device/simulator and clean and try installing it again.

App Rejected for failing to launch? ...and others

My game was just rejected from the AppStore for the following two reasons...
We found that your app failed to launch on iPhone 4 running iOS 5.1,
on both Wi-Fi and cellular networks.
We encountered the issue when selecting the application on the Home
screen - the app displayed a launch image then quit unexpectedly
And
Your app did not run at iPhone resolution and/or 2x iPhone 3GS resolution when reviewed on iPad.
Both of these confuse me, I currently do not have Lion installed so cannot test in 5.1 but, it works just fine in 5.0.1 and below.
Also, I have been testing on only my iPad, have no iphone to test on, but the game and graphics run just fine on the iPad. Though! I only have graphic files labeled #2x.png, and none with out it. Could that be the problem here?
If anyone has any advice that would be awesome, I responded to apple's rejection, but i bet it takes a while for them to get back to you, and i'd really like to move this along. Thanks!
**Updated
My didFinishLaunchingWithOptions:
Is as follows
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
mainMenu = [[MainMenu alloc] init];
self.navController = [[UINavigationController alloc] initWithRootViewController:mainMenu];
self.navController.navigationBar.hidden = YES;
[self.window addSubview:navController.view];
[self.window makeKeyAndVisible];
[[GCHelper sharedInstance] authenticateLocalUser];
if ([[[NSUserDefaults standardUserDefaults] objectForKey:#"missingWordsAdded"] intValue] != 1) {
[self forceAddWords];
}
if (![[NSUserDefaults standardUserDefaults] objectForKey:#"EnableSoundEffects"]){
[[NSUserDefaults standardUserDefaults] setObject:#"YES" forKey:#"EnableSoundEffects"];
}
return YES;
}
GCHelper sets up GameCenter. thanks!
I've got a few suggestions:
Do a reset on your simulator, launch your program and see if it works
Uninstall your app from iPad, run it from Xcode and see if it works
Ask a friend to test an ad-hoc copy, or attach to your Xcode and run debug copy
Depending on your implementation, you should do some blind check on your startup code (didFinishLaunchingWithOptions or singleton instances). Especially those area that involves GCD, #synchronize, access on NSArray or NSDictionary. And things like default preference initializing and database creation are likely to produce this kind of problem.
Regarding the review process, my log indicates that Apple staff at Cupertino uses an iPad 2 with WiFi connection to run your app. They are not toying with you if they say they can't run your app.
1) "app failed to launch" for different configurations of phone and iOS is a big issue to reproduce because you may not have all the phones with different iOS versions at hand. You can try https://testflightapp.com/ for example, and can come to know your app performance with different configurations.
my app is also rejected for same reason. here u have first check the internet connectivity where it will needed than u have do your code.
to check internate connectivity u can use reachability classes.

Strange leak when using QuickLook framework in iOS4.0

I have used QuickLook framework for opening one 2 page pdf file modally, and everything works. However, after testing (Instruments Leaks) the project with different iOS versions and devices, I have noticed strange leak that was appearing when running Intruments leaks on iPhone 3GS + iOS 4.0 device. The leak was appearing after opening previewer modally on the parent view and closing previewer. Strange, but no leak was appearing when testing on simulator and iPhone 4 + iOS 5.0. I'm using Xcode 4.2.
The code is pretty straightforward. Here's a button action that opens previewer modally:
-(IBAction)openFiles:(id)sender{
QLPreviewController *preview = [[QLPreviewController alloc] init];
preview.dataSource = self;
preview.currentPreviewItemIndex = 0; //for previewing only one pdf file
[self presentModalViewController:preview animated:YES];
[preview release];
}
Here are the details for a leak in Instruments:

ABPeoplePickerNavigationController crashes on init

I'm using ABPeoplePickerNavigationController in my project. I have a line that looks like this:
ABPeoplePickerNavigationController *peoplePicker = [[ABPeoplePickerNavigationController alloc] init];
It works fine when I have my deployment target set to 4.3. When I change the deployment target to 4.2, it crashes on this line w/ EXC_BAD_ACCESS. I ran w/ NSZombieEnabled and no zombies turned up.
It works fine in 4.2.
Clean All Target.
Delete App, Turn off iPhone and Xcode.
Project Info => Check Base SDK (General Tab & Build Tab)