application crashing on clicking back button in navigation controller - iphone

I have a table in my view controller (navigation controller). It contains 5 rows. When I click on one 3rd row, a new view controller is pushed onto the stack. This new controller also contains a table view and the cells in that table view contains text fields (added using cell.contentView addSubView:). On clicking one of the text field, a picker is shown (using textField.inputView) instead of keyboard.
Now, without selecting any item in picker, I click on back button, then my view gets popped. But after a while (when I am on my root view controller), the app gets crashed.
But If I click on a text field (which is showing keyboard), and then press back button; no crash occurs. So, what might be the problem??

Looks like you have some bug in your logic. Try to Build and debug and see in debugger(run-debugger) stack of calling functions.

If you use a pointer without initializing it to nil or any other object, you are propably going to end up accessing memory which isn't yours. this type of code will also give an EXC_BAD_ACCESS error , that means you are truing to use memory which is not yours. so first trace your code using break points line by line.

Related

iPhone Storyboard, programmatically calling segues, navigation issues

So I have an iPhone app. It has a simple structure, all based on a UINavigationController.
I have a storyboard that has one view, a segue to another view, etc. Now this other view has a UITextView that I do not want to edit on this screen - if the user taps this, I want it instead to fly over to a second screen which basically has the same text view, but this one is full-screen, and the user will edit the text on that screen before returning to the previous screen.
So I capture the textViewShouldBeginEditing method. I previously, in the storyboard editor, manually created a push segue from the previous view controller to this new view controller, and named it so that I can call it by it's identity, which I do with:
- (BOOL)textViewShouldBeginEditing:(UITextView *)textView
{
// This is called when the user clicks into the textView as if to edit it.
// Instead of editing it, go to this other view here:
[self performSegueWithIdentifier:#"editMemoSegue" sender:self];
// Return NO, as I don't actually want to edit the text on this screen:
return NO;
}
Seems reasonable. And it works. Sorta. It does in fact shoot me over to that other view. That other view's events fire up, I set it's text view to become first responder, I edit the text on that screen. Everyone's happy.
Until I want to use the back button to return to the previous view.
Then I quickly find out - my navigation stack is foobared. Most of the time, I have, for some reason, TWO instances of my new editing controller on the stack, so the first time I hit the back button I get the same stuff over again. Then, oddly, occasionally, it will work as intended, and I will see my previous controller with only one back click.
I started reading the log, and I found this:
2012-12-09 09:41:03.463 APP[8368:c07] nested push animation can result in corrupted navigation bar
2012-12-09 09:41:03.818 APP[8368:c07] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2012-12-09 09:41:03.819 APP[8368:c07] Unbalanced calls to begin/end appearance transitions for <SecondController: 0x83881d0>.
So obviously, I'm doing something incorrectly here. The question is, what? And how do I do what I want in the way that correctly appeases the tiki gods of the iPhone framework?
Check to see if the textViewShouldBeginEditing is being called twice. I've noticed that these kinds of delegate calls sometimes are.
How is your #"editMemoSegue" being created on the storyboard? is it created from the textView? if it is then you should recreate it directly from the view controller or from the top status bar on the view controller that way it wont be called twice when you touch the trigger object and when you call it programmatically.

Add data with another view on app objective c

I am trying to write a project but with out success i need help:
in the first view i have UITableView with a + on the navigator bar than after i push on him
I open a another view there i want to add a first name and after then i click "Done" i want the name i wrote in the textfield will appears on the first view
and thats is my problem the name are not appears in the first view and i have not bug or error .
what can be missing in my project all the button are connected.
I need some help please.
Since you're not showing code, I have to have a pretty general description here. With a button in the nab bar (which is what I think you're talking about) the button calls an action method. Your action method is what moves you to the second view.
Even if your button is "wired up" correctly in your xib file, your action method may not be doing the right thing. I'd try setting a breakpoint in your action method to 1) see if it gets called and 2) step through to see if you're creating a new view and pushing it on the UINavigationController's stack.

Navigation View and Tab Bar make iPhone app quit

I'm currently programming an app for iphone that uses the tab bar. One of the views it links to uses a navigation controller so that i can drill down the table view that I am using to display info to the user. It all works OK I can drill down the table view no problem, i can push the current table view off the view stack and return back up the stack to the first view using the back button in the navigation bar.
The problem I have is that if I drill down more than 1 view level and press the tab bar button for that view the application exits and Xcode shows a EXC_BAD_ACCESS.
The tab bars button is obviously trying to jump back to the first view in the stack, but should it be doing this?
If so, how do I make the button push everything from the stack or is it possible to disable the tab bar button from that view trying to show the top view again?
Its not really desirable for the whole app to return to the first view if the user accidentally taps the button.
Any help appreciated :)
I had an autorelease set on the view object I was trying to link back to from the tab bar and hadn't noticed that I was also releasing the same object in the dealloc method also. So when I viewed the view the first time I clicked the tab it was still in memory but when coming back to the view its retain count had been set to zero removing it from memory altogether.
Solved it by removing the release cal in the dealloc method. Alternatively removing the autorelease would have done the same thing.

iphone view controller methods not being called but view shows

I have a navigation controller with a UITableView which when goes to another view when a row is selected. When this loads the breakpoints get hit.
Good so far.
When I hit the back button, the table view appears fine, with data.
However, even though I have breakpoints enabled in the viewcontroller, none get hit like when it originally loaded! But yet, the data loads fine. The only breakpoint that registers now is when I click on a row (didSelectRowAtIndexPath).
Where are the breakpoints set that you are expecting it to break?
Perhaps you need to call the following in the viewWillAppear method...
[self.table reloadData];
It would depend on where your breakpoint is actually located. If you have a breakpoint in viewDidLoad method, then it will only be called once when the view is first created. When you go back from another view, the view is not loaded again. So the breakpoint will not hit. However, viewWillAppear method will be called.
You are using a navigation controller here. Navigation controller holds a navigation stack, which includes UIViews on top of each other, with the visible one on the top.
Now, let's say the table view was loaded, then you move to another (which is now the topmost view in the navigation stack). Note - the table view is not gone. It's there, just under the view you are currently presenting.
Thus, when you move back to the table view, it is not reloaded, because it was never gone (released), just hidden.
There are exceptions to the above, and sometimes a view which is not presented on screen will be released (low memory scenarios situations, for example), but you can't count on it.
The UINavigationController Class Referance explains this concept very well.

UINavigationController reloading UITableView

In my application I am parsing XML to create a UITableView. When a user selects a row it changes the file that it is parsing and reloads the UITableView.
I want to create a back button so that the user can go back the the previous XML page they were viewing.
In short how can I tell the navigation controller to create a back arrow for this page when all i am doing is reloading my UITableView?
I'd strongly suggest building another controller (i.e. UITableViewController) and push that instead of just reloading the table. This makes the button automagically, and (major plus here), it animates the whole digging down / stepping back in a way that the user is expecting it.
As a side note, I didn't manage to get a back-style button once I tried it, just a plain normal button (make a new button and set it at the navigation bar).
What you're describing is a navigation. Rather than reloading the table's data, simply push a new view controller onto the navigation stack every time a row is tapped. This is a fundamental pattern in iPhone development. Here is Apple sample code for a multi-level drill down table view.