ABPeoplePickerNavigationController crashes on init - iphone

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)

Related

Xcode5 build universal app for iPhone in iPad store

I found a problem with my build, looks like Xcode5 changed this in comparing to Xcode4.
before, in Xcode4: I choose to build "universal" app and my app with iPhone size is scaled on iPad, can be found both in iPhone and iPad store.
now, in Xcode5: if I choose "universal", my app with iPhone size is no longer scaled on iPad, but keeps the original size while leaving the whole right part empty. If I choose "iPhone", it is scaled on iPad, but can no longer be found in iPad store.
I noticed UIDeviceFamily is removed from Info.plist in Xcode5
what I want is simply the same build result with Xcode5 for my app as with Xcode4. Anyone has any idea about it?
Here's my code to initiate the root view in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
DialoguesVC* dvc = [[DialoguesVC alloc] init];
HomeVC* hvc = [[HomeVC alloc] initWithRootViewController:dvc];
[self.window setRootViewController:hvc];
HomeVC is a UINavigationViewController.
Xcode 5 requires that a separate storyboard for iPhone and iPad is defined in the target for your universal app. You can however select the same one if you like. Here's how to do it:
In the Project Navigator on the left, select the bug blue bar at the top with your Project Name in it.
On the right, select your target from the drop down menu. This is where you define if your app is iPhone, iPad or Universal. In your case, select Universal (under Deployment Info).
You should now see two tabs in the same section: iPhone and iPad. Switch between them to define allowed orientations, Status Bar Style and - most importantly - select which Storyboard you're using for each device.
That should do the trick, and when run on an iPad, it should now load the iPhone storyboard as Xcode 4 would have done.
This may not look as attractive as you would hope - in which case you can copy your iPhone Storyboard and make changes specifically for iPad. I've explained how to do this here: http://pinkstone.co.uk/how-to-convert-your-iphone-storyboard-into-an-ipad-storyboard/

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.

MFMessageComposeViewController on Simulator - canSendText?

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

Adding iPad XIB/VIEW to a "View Based Application" in iOS 4

I've created a View Based Application in XCode4 and trying to do the code and UI design according to the way Apple have intended it to be.
So I designed the UI in the AppNameViewController.xib and it works fine; now I want to enable it as a UNIVERSAL application that runs on iPad as well. I changed the App-Target>>Summary>>Devices from iPhone to Universal and miraculously XCode had automatically created MainWindow-iPad.xib (Apple, very nice...), but since I designed the application first screen on the AppNameViewController.xib and not on the MainWindow.xib when I run the app on iPad Simulator I get this ugly screen where my UI objects size and location is distorted (their size is still set for iPhone so they are all crumbled on the left-top corner of the screen).
In my previous app I used the code appearing below to distinct between the AppNameViewControllerForIPHONE.xib and the AppNameViewControllerForIPAD.xib; It was done from the AppDelegate.m file, but in the new XCode View Based Application template the AppDelegate doesn't go through initWithNibName method at all.
Code I used on XCode 3 that cannot be used on XCode 4:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
viewController = [[AppViewController alloc] initWithNibName:#"AppViewControllerIPAD" bundle:[NSBundle mainBundle]];
}
else {
viewController = [[AppViewController alloc] initWithNibName:#"AppViewControllerIPHONE" bundle:[NSBundle mainBundle]];
}
Long question... still, anyone had any idea how it should be done here? Where should I design the iPad UI or is there a way to easily transform the iPhone xib to an iPad one?
You have to follow the new naming scheme (idiom in Apple-speak) specified for Universal Applications for the NSMainNibFile key in your info.plist. For example, if you set your NSMainNibFile to be "MainWindow-iPhone", the xib for ipad would be "MainWindow-iPad".
The same naming convention should hold for the views in a view based application (I can't test right now, installing new xcode).