Navigation corrupted - ViewModel can't close? - xamarin.ios

On every other place the navigation just works fine, only on this place it doesnt work (it's set up like all the other Viewmodels)
I'm trying to navigate from ImportView (ImportViewModel) to the LoginView (LoginViewModel).
On Buttonclick (Binded MvxCommand in ViewModel) I'm calling ShowViewModel<LoginViewModel>();
Its working but afterwards the whole navigation is broken. If I move now from the newly opened LoginViewModel to for Example TestViewModel (or TestView), and now going "Back", I'm not coming to the LoginView back, instead to a BlackScreen and there is one more "Back", after that the App crashes... (MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSInvalidArgumentException Reason: Can't add self as subview)
Where is here the Problem?
Here some Debuginformations:
[0:] mvx:Warning: 26.41 Don't know how to close this viewmodel - topmost view does not present this viewmodel
[0:]
2013-12-13 13:19:28.400 INMobileAdminUIiOS[6932:60b] mvx:Diagnostic: 26.81 Showing ViewModel LoginViewModel
[0:] mvx:Diagnostic: 26.81 Showing ViewModel LoginViewModel
[0:]
2013-12-13 13:19:28.799 INMobileAdminUIiOS[6932:60b] TouchNavigation:Diagnostic: 27.21 Navigate requested
[0:] TouchNavigation:Diagnostic: 27.21 Navigate requested
2013-12-13 13:19:29.085 INMobileAdminUIiOS[6932:60b] nested push animation can result in corrupted navigation bar
[0:]
2013-12-13 13:19:29.224 INMobileAdminUIiOS[6932:601f] 13.12.2013 13:19:29 TinyMessage: ProgressDialogDismissMessage
[0:] 13.12.2013 13:19:29 TinyMessage: ProgressDialogDismissMessage
2013-12-13 13:19:29.463 INMobileAdminUIiOS[6932:60b] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.

I solved the problem.
I added this.NavigationController.PopToRootViewController(true); in viewDidAppear
The problem happens when the view controller tries to pop to top view controller without waiting for the loading end of child view controller. popToRootViewControllerAnimated() must be called after the view appears!

I have solved the problem.
I added
this.NavigationController.PopToRootViewController(true);
in viewDidAppear

Related

ios7 navigationbar causes EXC_BAD_ACCESS after VC with keyboard shown dismiss

I have a Notes-like app: UITableViewController showing up individual notes by pushing them onto navigation stack.
The problem arises when I have UITextView with the FirstResponder status (keyboard is shown) and I touch Back button. The current view controller is dismissed with the animation as expected, BUT the navigation bar is broken now! If I press any of the bar buttons, it will cause EXC_BAD_ACCESS.
I would say that it was not transitioned properly. The table VC is broken somehow as well, as it may appear empty on further manipulations... Very strange behaviour!
By the way, it did not cause any problems with iOS5 and iOS6, but there I used a custom chevron Back button.
I've checked the standard Notes app and it works like a charm.
What is the trick?
Thanks a lot for your advice!
EXC_BAD_ACCESS means you are trying to access an object that has been deallocated. Best thing you can do to trace this is enabling NSZombie, it will tell you what released object is being sent a message (aka EXC_BAD_ACCESS).
You can get how to enable it from here.
I got it and will try to explain to help somebody else to save their day...
EXC_BAD_ACCESS was raised because UITableViewController was not properly transitioned to during Back pop-animation (its viewWillAppear: and viewDidAppear: method were not triggered at all).
In its turn, the animation was not properly performed, as popViewControllerAnimated: was called twice or even more times: 1) as part of the system Back-button callback; 2) inside textViewDidEndEditing: in case no text was entered.
The solution is to check whether the back button has been pressed before calling popViewControllerAnimated:. The trick is to check if the detail-view controller is still in the navigation stack.
Here is the helper method:
-(void) returnToTheListOfRecords {
self.textView.delegate = nil; // this is to avoid the second call of `textViewDidEndEditing:`
if ([self.navigationController.viewControllers indexOfObject:self.delegate]==NSNotFound) {
// Back button has been pressed.
} else {
[self.navigationController popViewControllerAnimated:YES];
}
}
The problem happens on iOS7 only due to its brand-new animation.

Avoiding from MomoryLeak while performing Segues

I can use navigation without segues (1) but I would like to use it (2).
Performing a segue and navigating back make my app slower ! Because it doesn't dispose destination view when I navigate back. How do you use this segues in a right way ?
/*1) This code ok! But what about segues */
if(_tabbarController==null)
_tabbarController = (UITabBarController)this.Storyboard
.InstantiateViewController ("MainTabbarController");
this.NavigationController.PushViewController (_tabbarController,true);
/*2) If I run this code I get a new instance of UITabbar */
this.PerformSegue("SegueShowDetail",this);
If you're using the Storyboard and a Navigation Controller, the navigation controller should automatically release your view and associated memory with it when it pops off the stack.
For example, if you've got a method that gets called when you push a button to go to another view, you'd have:
[self performSegueWithIdentifier:#"mySegueName" sender:self];
When you click the back button at the top left of your secondary view, this will trigger the navigation controller to dispose of the view.

Receiver has no segue with identifier

I have a problem that I've been sitting with all the day. I have a super view which contains UIPageControl and UIScrollView, in this super view. I have created a sub view which contains three images, three labels, and three buttons. Each button has a touch up event. When the button event is triggered the super view will be promoted by a new view. For doing that, I created a segue which connected with super view and new view. Here is the connection code in the super view.
`
<connections>
<outlet property="pageControl" destination="ivy-0Q-UQo" id="rGm-sh-mdE"/>
<outlet property="scrollView" destination="4Yu-Qb-kbF" id="aqY-ou-cv4"/>
<segue destination="zZo-CH-P2Y" kind="push" id="xBU-ZO-u7s"/>
</connections>
`
This piece of code will guarantee the connection between the super view and the new view is okay,
here is the touch up event code.
WelcomeFrameViewController *welcomeFrameVC = [WelcomeFrameViewController alloc]; //super view instance
NSLog(#"=======================");
[welcomeFrameVC performSegueWithIdentifier: #"ForwardToLogin" sender: self];
When I run the program, the compiler complains with
2012-08-20 10:17:02.325 TTRen[2440:f803] ============44===========
2012-08-20 10:17:02.352 TTRen[2440:f803] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver WelcomeFrameViewController: 0x688e960 has no segue with identifier 'ForwardToLogin''
I am quite new in iOS, any suggestions will be deeply appreciated.
'Receiver WelcomeFrameViewController: 0x688e960 has no segue with
identifier 'ForwardToLogin''
In your storyboard, check that you actually have a segue named "ForwardToLogin"
There does seem to be a bug with xCode (still in 6) where storyboard changes you make aren't get copied to the simulator. You can reset the Simulator's Content & Settings to resolve this.
Other things to check:
Check the naming of your segue. Check it again. Check it some more :-)
Ensure that your segue is pointing in the right direction. It needs to point away from the UIViewController that calls performSegue….
Ensure you don't have two copies of your view controller on top of each other, with the segue attached to the one on top, and you instantiating the one underneath!
There's a similar question here and I encountered the same problem too. The reset fixed it for me.

iPhone - UITextField inside NavigationController Crashing App when touched

I have a problem witha UITextField.
Context:
I have a UITabBar Controller with 5 Tabs. Each one has a NavigationController with their related ViewController.
First Tab, has a UITable. When a row in the table is touched, the user is sent to the second tab, and a new view is pushed in the NavigationController.
This new ViewController has a UITextField. When I touch it, the App Crashes with the message in console:
"-[CALayerArray registerDefaults:]:unrecognized selector sent to instance 0x612f280
***Terminating app due to uncoaught exception 'NSInvalidArgumentException', reason: "-[CALayerArray registerDefaults:]:unrecognized selector sent to instance 0x612f280"
Also I've noticed this ViewController also is not responding to Orientation Change... so I assume is something related to the tree...
Everything was constructed with the Interface Builder.
If you have any tip or idea of what can be happening, I'd really appreciate it.
Thank you very much.
in IB, deleting and adding a new UITextField should do the trick.

How do i refresh a tableview after returning from Background

How do I refresh a tableview after returning from Background(when the user hit home button and comes back later). Its not calling the viewWillApper delegate method.
Thanks,
Shinto.
Override applicationDidBecomeActive or applicationWillEnterForeground in the appDelegate. Then I would either call the table view controller to reload or use a NSNotification.
Note: applicationDidBecomeActive is also called when the app launches. See: Understanding iOS 4 Backgrounding and Delegate Messaging
u can do it in the Home Button. First Get the ViewController thats hold the TableView and do further action...

Resources