I have an app with a tab bar controller with 4 tab bar item , every tab bar item display a view controller and viewDidLoad start a query parse Method .
From first ios8 beta when the device ( or simulator ) change orientation the app launch all view controller viewDidLoad method and consequently start query parse Method in all view controller !
How can i stop this !
Where am I missing?
Thanks so much!
P.S. : Excuse for my terrible english ;-)
This seems to be the behavior going forward. You'll need to change you code to handle it. You'll have to move it to view will appear possibly with a bool/date to track when you last loaded your data.
You'd need to refactor something like this:
Create a BOOL property for the VC something like loadedData
Take your loading code from viewDidLoad and move it into viewWillAppear: wrapped in a check if (!self.loadedData) { }
Related
I would like to create a "deep link" into my storyboard while preserving the backstack (back button navigation).
Ex:
Given the storyboard below (entry point being the leftmost Navigation controller)
When my application is opened via a remote notification I would like to open the second tab in by tab controller AND be able to navigate back to the item list via the back button.
Please note that I am not asking about how to open the second tab, or how to create such a storyboard but specifically if there is a way to do this with storyboards or will I have to do it by code.
Thanks!
PS: I come from an Android background where one recreates the parent view controller manually or (better) inserts it into the backstack. As far as my research goes there is no such thing in ios. I'm hoping I'm wrong.
Your UINavigationController has a viewControllers property. You can create as many view controllers as you want in an NSArray and assign it to this property and that will be the back stack with the last VC in the array displayed.
The problem is that when a notification arrives, your app could be in any state at all. It could be running, with some other screen showing. It could be suspended, with some other screen showing. Or it might not be running at all, and will now have to be launched from scratch.
Thus, starting in the App Delegate routine that responds here, you will have to deal manually (in code) with the situation if you want to put your app into an appropriate state.
I have a One main view controller and in that I am having two sub view controllers named like rightViewcontroller and leftViewcontroller. When we press the menu items from the right view then I am changing the left view controller.That's working fine.Here my problem is If I get any alert that's only fixed to any of the View controller's.Then user able to press the other view which is not having the alert(those are custom alert's. I need custom alerts as per the client requirement)in iPad. Please Help me
Thank's in advance
When you get an alert on, say, the leftViewController, then disable the user interaction on the other viewControllers.
something like:
rightViewController.view.userInteractionEnabled = NO;
It seems when you present your alert you are showing it over one of the views like showInView:self.view when in fact you should show it over the parent view so it covers both like showInView:self.navigationController.parentViewController.view (that's just pseudo code).
Without seeing your code you use to present it currently I can't give you exact code.
Another way would be to first get a pointer to the parent view controller or navigation controller and show it there.
I have two ViewControllers. The first has UITableview that I push data from to the second ViewController. Whenever I go back, the first ViewController loses its properties - Its navigationbar background disappears and for example the sidebar menu does not work either. Is there any way I could reload it while pushing the back button?
Thank you
Sounds like you are probably doing your setup in viewWillAppear instead of viewWillLoad. This means that when the view will appear on return, the setup is happening again and perhaps leaving you in an unexpected state. Put breakpoints in your view controller delegate methods and see what order things are being called in and why.
I'm going to preface this question with the fact that I'm a complete novice in IOS, and I'm trying to learn as I go here.
The app I'm working on has a single Navigation Controller containing a Title Screen View Controller containing the app options. When I click the start button in the Title Screen it takes me to the Main Game Screen View Controller which has a CCLayer for doing some simple Cocos2D animation. All of this is working very well. Here's what I'm missing. I'm trying to programmatically go back to the title screen. I'm thinking there might be 2 options
1 - End the CCLayer somehow which will return me back to the Main Game View Controller where I can then send a command to go to the Title View Controller?
2 - Get a reference to the parent view controller of the CCLayer, and do the same as above.
I've scoured the internet for a couple of days trying to find what to do, and I'm out of ideas. I don't really have anything to show apart from I think I need to initialize the Title View Controller again.
Any ideas will be appreciated, thanks for your time.
well as you mentioned, you have a navigation controller which means that your Main Game View controller is pushed over your Title View Controller.
and your CCLayer is added on MainGameView Controller
so all you ever need to do is to pop your MainGameViewController. that shall automatically take you to your titleViewController.
You just need to write in your acton method
[[CCDirector sharedDirector] popScene];
You will be in previous scene.
My app use a custom navigation controller.
When I push UIVIewController up on the navigation stack I have to load data over the network.
I use :
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) {
});
to load my data so the app is still responsive and so the user can press the back button which uses :
[self.navigationController popViewControllerAnimated:YES]
When data has been loaded I often refresh UIElements like UITableView, UILabel... when we press the pushBack button the controller is no more the current controller so when the elements are refreshed everything crashes.
So I have two questions :
How can i know if the controller where the refresh is set is the current controller or not ?
I think i have miss something, does Apple did not know it would happen and they have a probably set something for it ?
Thank you for any help, sorry for my English.
Show a activity indicator while you are loading the data . Till the time data is getting loading do not allow the user to pop the current view controller . this could be implemented by adding a transparent view to the current on the top and remove the transparent view soon after the loading is completed . This functionality could easily be implemented using MBProgressHUD .
Here is the Link : https://github.com/jdg/MBProgressHUD