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

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.

Related

UISearchController disappears when pushing a new UIViewController

I'm currently working with an example from Raywenderlich: UISearchController-Tutorial (The finished project is at the end of their article or here) and I noticed that when I execute a search and click on one of the results, during the push transition, the UISearchController disappears. It's visible on this video: here
Before selecting a result
During the transition to the new VC
I run this example with Xcode 10, iOS 12 (sim: iPhone 8)
Any idea / pointer would be deeply appreciated
Cheers.
Its default in iOS12. Just look at the Apple-Mail App. There it is the same. Actually you dont need the searchbar, when you are showing another VC

Storyboards in Xcode 6

I have recently started to learn iOS with obj-c from "iOS Programming The Big Nerd Ranch Guide 4th Edition". This edition was released in 2014 and is written with Xcode 5.
I am trying to make a simple app with two buttons and two labels. The labels are connected to two arrays and when a button is pressed an object from the corresponding array is shown in the corresponding text label (it's the Quiz app in chapter 1).
I created the project as a Single View app in Xcode 6, and put all my objects in the view controller class. I have two labels two buttons two arrays and an int to keep track of the object that has to be displayed from the array.
In the book it says that I should initialize the arrays in the initWithNibName method. I tried that but for some reason it never gets called. So I changed the initialization of the arrays to the init method. They initialize fine but when they are called from another method they are nil. Do you have any idea why this is happening?
The second issue I'm having is that I can't manage to get the contents of the storyboard on screen. It says that I'm supposed to make an instance of the ViewController inside the AppDelegate and make it the root window controller but all I get is a white window (or black in case I don't set the color).
UPDATE: I changed the intialization of the arrays from the init method to the viewDidLoad method and now they seem to be working fine. Nothing on the screen though.
It sounds like you're initializing your UIViewController from the app delegate AND a storyboard. If you create a new project in XCode, a "Single view application", you won't have to touch the app delegate at all in order to get something on the screen.
I believe both your problems are related to this, since it sounds like you're seeing an empty UIViewController on the screen (the one you create in the app delegate)
As for the initialization of your array, viewDidLoad is a popular place to do this.
If you are using storyboards, the method initWithNibNameOrNil will not be called. In the BNR book, it teaches you to use XIB files, which do use this method. If you are trying to follow the tutorials, I would suggest using XIB files.
For use of a book, I would suggest downloading whatever version of Xcode is being used for that book -- otherwise you will be running into a lot of confusing problems while learning.
If you would like to download previous version of Xcode, refer to this post:
How to download Xcode DMG or XIP file?

Swift UIPopover storyboard

I am getting started with Swift right now.
I am rebuilding an old app completely in Swift. It is an iPad-only app.
Right now I can't get UIPopover working.
I am trying to tie a button in a view(1) to another view(2) with segue "Present as Popover".
None of the elements I add to view(2) is shown in the popover in simulator. It is always a blank / white view.
Any help is appreciated!
Is this for iOS 8? If so, try using the "popover presentation" action segue.

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.

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

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/

Resources