ios methods becoming zombies - ios

I added uiviewcontroller subclass in my arc enabled project, i added a button created the ibaction for it and inside it contains no code, all done through interface builder no manual code, but when i am tapping the button i am getting exc_bad_acess. Instrumentation saying its a zombie attack when pressing button. I really dont understand whats going wrong. I created the new project and done the same thing it is working perfectly. Same thing happening when i am defining method to dismiss keyboard (resign first responder).
this generated when i crtl+dragged from button to interface implementation, i choose the ibaction and name and this code is generated.
- (IBAction)pushh:(id)sender;
and the implementation inside .m file
- (IBAction)pushh:(id)sender {
}
thats all ...

Just to wrap up the offline conversation, a couple of thoughts:
Your zombie is undoubtedly a result of the ecnObj falling out of scope. If it's an ivar of the view controller, then that premature release problem goes away.
You do not want to create a new view controller and then use its view in transitionFromView. If you want to transition between view controllers (in iOS5) you should use pushViewController or presentViewController (or if you're using a container view controller, you can pursue transitionFromViewController). See View Controller Programming Guide's discussion of "Presenting View Controllers from Other View Controllers".

My solution was to delete the button iboutlet in ib, also delete the ibaction in ib, and then connect it back.

Related

UIStoryboard segue fail

I created a simple Show segue by dragging from a UIButton to another UIViewController in storyboard view. It's configured as all of my other VCs and has a custom class that is specified, with linked IBOutlets and IBActions (which appear to link up when I hover on them).
NOTE: When I first created it, there was no view controller class specified. I've recreated it several times since then, but I'm wondering if some value is cached that's pointing to a default view controller. Although I get print lines from the correct view did load method...
For some reason, when I run the app and click the button it links to a black, empty view controller. The navbar pops up without any back button (these views are embedded in UINavigationController).
After looking up other posts about this kind of issue, I've deleted and recreated the segue, cleaned my build folder and restarted Xcode. There's no source code involved in this, just storyboard configuration. Any help on next steps?
According to the code shown in your screen shot, the problem would be that NodeEnrollmentViewController is a subclass of UINavigationController. That's wrong. It should be a subclass of UIViewController.
You cannot (and do not need to) segue from a view controller within a navigation controller to a navigation controller.

Xcode tap gesture causing error

I created two views in Xcode using the hierarchical view layout. I initially created a button on the first page (PlaylistMasterViewController) which activates the segue method to transition to the next page in the hierarchy (PlaylistDetailViewController), which worked just fine. I then deleted the button, and added a tap gesture to one of the UIImage view elements in the masterViewController and deleted the button. I created the action outlet of the touch gesture to activate the segue and made sure to delete all of the uses of the button in my code, yet this error is thrown once right after the splash screen loads (run time). Any ideas what might be causing this?
In your storyboard check your PlaylistMasterViewController for a connected outlet named showPlaylistDetail with a little while exclamation mark next to it. Then hit the 'x' and clear that outlet connection.
It's most likely some outlet you previously connected and later removed from your code.
The image below is just an example to show you what it would look like.
most common - you have outlet from ViewController to your deleted button in storyboard
You might have deleted the button but something in the view itself may still be referencing it. As the view is loaded at runtime when you try to bring up the view it may have UIButton connected to an outlet that no longer exists.
Open the view in Interface Builder and make all the ui elements in that view are properly wired up and not referencing a non-existent IBOutlet. If there is a problem you'll see a yellow warning icon to indicate a problem.

Swift Changing View with performSegueWithIdentifier / programmatically

So I am trying to programmatically change views when some condition is triggered.
I have created a simplistic project, whereby I want to change to View 2 from View 1, once View 1 has loaded. In reality, there is some logical operation that checks if some variable is true, then it invokes the performSegueWithIdentifier function, however to keep this as simple as possible I have removed that code.
The steps I have performed are, firstly to create two views:
I then click View 1, and inspect its properties and then created a manually triggered segue to View 2
I selected the 'Show' option, so now my Views are connected by a segue
Then under attribute inspector, I give the storyboard segue and identifier of "GoToView2".
From there I go to the ViewController.swift file, and in the viewDidLoad function. I insert performSegueWithIdentifier code:
self.performSegueWithIdentifier("GoToView2", sender: self)
However, when I then run the code. View 2 does not load, and only View 1 appears in the simulator.
Any help and explanation would be greatly appreciated.
I have had the same problem with attempting to perform a segue inside the viewDidLoad function, and the error that comes up seems to be that the view you are attempting to load with the segue is not in the window hierarchy.
Changing the call to viewDidAppear seemed to fix the issue as mentioned in this other post: whose view is not in the window hierarchy (note the language is objective-c not swift, but it can be translated).
It seems you have to be careful at what point in the view lifecycle you want to change it to another view controller - at viewDidLoad all the views in the storyboard are not available.
BTW, without having a conditional in there, the segue will be fired (and load the view controller) every time the view is loaded!
I am working on a project that does exactly what you want to do. Perform segue with identifier is the right thing to do. My project also does the check in viewDidLoad.
All your steps look fine, so I believe it's a subtle issue. Check the identity inspector to see if you connected the view controller with view 1

IBOutlet & IBAction: do I put these in the view controller or the app delegate?

I have a project I created from a template following one of those books. I guess when the preliminary version was created, there was a view controller built into the project which I couldn't see (some default inherited object I suppose). Now, I have had to create a separate view controller. Do I move the IBOutlets and IBAction flags to the view controller? Or leave them in the app delegate? I hope I'm asking a reasonable question. Thanks.

iOS: UIViewController is Not Being Pushed Problem

I'm working on a new app where there is a "main" UIViewController with some UIButtons and once the user clicks on the buttons, the application is navigating to another UIViewController.
For some reason, the UIViewControllers are not opened, when you click on the button nothing happens. Several points that anyone who tries to help should be aware of
I'm using code and interface that are very similar to another app that I had created and is working fine (I triple checked the code, and it's the same in the area that makes the UIViewControllers navigation)
I triple checked the Interface Builder items and their connection to the IBOutlet us fine (view is connected to view, File's Owner is set correctly, etc...)
I inserted NSLogs to the UIViewController that is not being pushed and I can see that initWithNibName is being called, but viewDidLoad is not being called.
I'm using basic-simple code to create and push the UIViewController: alloc+initWithNibName and then presentModalViewController or pushViewController (none of them work) and as I said, in another app with the same mechanism it works fine.
I don't know where to look! Maybe I unchecked by mistake some "Enable" button in Interface Builder or something like that.
Did anyone encounter something like that or may have some new thought regarding to where I should be looking?
Hmm, strange. Things i can come up with now are: dit you call [super ] in your viewDidLoad?
Is it stacked behind another view? Run instruments to see if all the things on the pushed view are allocated, so you know if the whole view is loaded. And you use a navigation controller? than you use pushViewController. When you are not and want a model you use presentmodalviewcontroller.

Resources