Issue dismissing/ re-presenting MFMessageComposeViewController with iOS6 but fine with iOS5 - ios

I'm presenting an MFMessageComposeViewController which works fine with iOS4 and iOS 5 but has problems with iOS6.
The view is presented ok but if its dismissed and then represented it doesn't display correctly - only the To: line is displayed, the body and keyboard are missing. (Sorry I can't post a screen shot at the moment as XCode crashes when I take a shot, I'm downloading an older version of XCode as I type).
Stepping through the code in the debugger I noticed that the problem may originate earlier than the re-presenting - I noticed than when dismissViewControllerAnimated: gets called the entire view does not get dismissed immediately, rather it is the message body and keyboard that gets dismissed leaving behind the To:, the same thing that is displayed when the view is re-presented.
It might be easier to describe with screenshot, I'll post some shortly.
I'm using presentViewController: and dismissViewControllerAnimated: to present/dismiss the MFMessageComposeViewController.
+++ UPDATE +++
I've found the problem can be solved if instead of using the same MFMessageComposeViewController object to re-present the view I first delete it and then create a new one.
That seems a little inefficient though, and it should not be necessary I'd have though, like i mentioned it worked on iOS5.

In iOS 6 apple introduced a new feature "remote view controller". Some external view controllers are no longer part of your app, and the messaging controller is one of them.
I guess that is the problem in your case.
you can read more about it there: http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/

Related

shouldautorotate method not called

App orientation has suddenly stopped working as intended. I have an app with a tabBarController working mainly in portrait mode. Some VC's override this to allow landscape. The deployment target is iPhone on iOS 9.0+.
The shouldautorotate method is no longer being called anywhere in the app, but supportedInterfaceOrientations is called about 10 times (in the tabbarController) for each rotation (for different subVC's I guess).
This has all worked brilliantly before but if I check out an older branch where I know 100% that it worked, it still doesn't work. (I know this because I have a test build which works properly when I download it)
I've tried backtracking, cleaning, updating, reinstalling, re-downloading entire project, switching branches etc. but nothing works. I've gone through all warnings in the debugger output and tried a bunch of code solutions.
I'm wondering if it could be some sort of plist or project setting causing this. But, honestly, I hardly ever change project settings so I doubt it's that.
PS. This is not a duplicate of similarly titled questions. I've gone through them already. I'd be very grateful if anyone has any idea.
Autorotation is the bane of my iOS existence. There was a perfectly good way of doing this pre-iOS 6, then there was a new way of doing this in iOS 6, then another way in iOS 7, and yet another way in iOS 8. According to the UIViewController documentation:
As of iOS 8, all rotation-related methods are deprecated. Instead, rotations are treated as a change in the size of the view controller’s view and are therefore reported using the viewWillTransitionToSize:withTransitionCoordinator: method. When the interface orientation changes, UIKit calls this method on the window’s root view controller. That view controller then notifies its child view controllers, propagating the message throughout the view controller hierarchy.
Note that this method is called on the root view controller for the window, not the active/visible/whatever view controller. My root view controller dismisses any popovers then calls setNeedsLayout on its view. (I manually layout all my views so your requirements may be different.)

Black screen on app launch after latest Xcode 7.2 update

i am making a very complicated app with a lot of classes.
my app worked great and i worked on it for the last month.
the last time i worked on it i added a function and it worked great, i saved the app and ran it a few times since and it worked. the last time i turned my computer on, it prompted me that an update for xcode is available. i updated it, and since then every time i run my app it runs with no errors but on ios simulator it shows a black screen. what can i do? i worked really hard on that app. thanks for the help in advance.
There's few issues that could happened, withou detailed description of this issue, you can try following solutions:
reset simulator
check if your initial controller is set up in storyboard(select controller and press attribute inspector, select is initial view controller):
if you're setting initial view controller programmatically, check if that controller is not nil in app delegate
another tip - try to use UI debugger, that helps a lot:
Any debug messages in the Xcode output? That usually will give a clue.
One thing I can think of, is that in your
- (void) applicationDidFinishLaunching:(UIApplication*)application
delegate, try setting the window's root view controller to your view controller. Example:
[window setRootViewController:viewController];
[window makeKeyAndVisible];
Again, the Xcode debug output will confirm if this is indeed the case though.

UITextField can send its action twice. Is this an iOS bug, or did I make an error?

In iOS, I have a UITextField in a UITableViewController scene that is governed by a Navigation Controller. All static cells. The text field has the "Clear on editing" flag switched on. I want to get and save the value entered in the field, so I have the -editingDidEnd: action call my saveData: method in the custom UITableViewController subclass. If I click out of the text field, all is well. However, if I back out of the scene using the Back navigation button, then saveData: gets called twice. Once with the entered value, and a second time with an empty value. This appears to be incorrect behavior.
I've made a demo project and posted it to GitHub here: https://github.com/davehirsch/BugDemo
Am I doing something wrong? Is this an iOS bug? It seems unlikely that it's a bug nobody else has found (and I've looked around for others reporting similar things). I'm running the latest non-beta versions of Xcode and OS X, and the bug is happening in the iOS Simulator (but I'm not sure if it would happen on a real device, I guess).
Yes you are right. It looks like a bug in UINavigationController.
Before and after animation the method [UITextField resignFirstResponder] is called before and after animation. The first call is done by [UINavigationController popViewControllerAnimated:], and the second one in [UINavigationConteoller navigationTransitionView:didEndTransition:fromView:toView:] that call [UIView(Hierarchy) _removeFirstResponderFromSubtree].
Looks like your text field hasn't resigned yet as a first responder before animation ends.
[EDIT]
I recommend to look at rdelmar comment.

iOS7 UIToolbar crash

I have an iPad app that has been running fine until iOS7. This issue seems to be only on ipad 2nd gen models and earlier when iOS7 is installed. Anyway, I've been tearing my hair out trying to figure out where this error is coming from, but have had no luck. The console in xcode (5) reports the following error after I perform a logged in segue:
2013-11-18 11:17:31.768 MyApp[400:60b] *** -[UIToolbar backdropView:willChangeToGraphicsQuality:]: message sent to deallocated instance 0x18ec23e0
I can't lookup the address for more info (image lookup -a 0x18ec23e0) it just returns nothing.
In instruments running zombies, it reports that a message was sent to a UIToolbar like so:
When I inspect the instance, I get the following:
How do I debug this? I have no idea where this call is being made and it seems dependent upon a physical deivce (doesn't happen on the iPad mini or ipad 3/4)
I was struggling with a very similar error, also with a UIToolbar, that I couldn’t figure out until a couple hours ago. I also had to use and try to understand the zombies’ instrument but without any luck.
What I did was to pay a close attention to the call stack that was presented when the Exception Breakpoint was activated as described in the following tutorial:
http://www.raywenderlich.com/10209/my-app-crashed-now-what-part-1
Even though the call stack didn’t point me to the exact code line, I noticed that the app was trying to add a UIToolbar to a ViewController. Turns out that what I was doing was creating a local UIToolbar inside of a method and adding it to the presented UIView. After have modified this behavior, I stopped having the annoying sudden crash. It was difficult for me to find the issue because looking at the code of the ViewController that caused the crash, there was no code that created or used a UIToolbar; however this VC included a custom view that did exactly that, as I explained before.
Have said all of this I recommend you to closely inspect the VC that generates the crash. If you need to create a UIToolbar programmatically I recommend you to declare it as a strong property to maintain the memory reference as long as needed.
I hope this helps you.
I struggled with this for a while today. I had two storyboards, one for login/signup (set as the main storyboard for the project) and another with the rest of the application. The app delegate would detect if a user was logged in and instantiate the root view controller of the other storyboard. The root view controller of the login storyboard is a navigation controller and after after some investigation with instruments I realized there was a UIToolbar being instantiated from the nib. Opening up the storyboard file revealed an off-screen UIToolbar object in the root view controller. I deleted it and I'm not crashing any more.
I should also mention this crash was only occurring when I was using MKMapView.

UITapGestureRecognizer from Objects library in storyboard on a view which is inside a tab bar controller

I added a UITapGestureRecognizer to a view which is inside a tab bar controller and when I switch to the tab which contains the view with the UITapGestureRecognizer, I get a crash with the message -
-[__NSCFString setView:]: unrecognized selector sent to instance 0x2ae8d0
I am using Xcode 4.3
i had this same trouble on iOS5 only with an app targeted to iOS 5 and iOS 6 and a gesture recognizer on the last tab. our code also has very similar gesture-recognizers that are loaded for modal dialogs or pushed view controllers for other tabs. so it was only gesture-recognizers in a tab that was not the first tab, and only in the rootViewController for that tab.
as Arunabh Das ended up doing, it would seem the only answer is really to add the UIGestureRecognizers in code. there is a thread at Ray Wenderlich's website (which is a decent site containing some good iOS tips) , which, summarized, notes that there appears to be a bug in iOS5, starting with the beta versions, never fixed in the final, and containing a code-snippet that shows how to put the gesture-recognizers in code if you want them.

Resources