Using viewdeck, while closing leftView chenterView appears but but not reloaded - objective-c

I'm using ViewDeck library to use side panel functionality and it works fine. My application needs the centerViewController to be reloaded while I click some button from LeftViewController.
and it should be reloaded after appearing the centerView.
#import TCenterViewController.h
....
- (void)ViewDidAppear:(BOOL)animated{
// code to reload the view
}
And m calling it from LeftViewController.
[self.viewDeckController.centerController viewDidAppear:NO];
Its working. but taking the time to load before the view appears. how can I reduce the delay??

I know it's a bit late, but in case someone still needs the answer. You need to insert your update code in
- (void) viewWillAppear:(BOOL)animated
this method is called every time the scene appears. However, this is not the case with viewDidLoad.

Related

UITextField losing firstResponder after view appears

I have a UIPageViewController. One page has a single button, and the other page has a UITextField with a button. When the page scrolls to the view with the field, I'd like it to becomeFirstResponder and open the keyboard. Here's what happens:
I call [self.locationQuery becomeFirstResponder] ViewController's viewDidAppear method. But it never opens the keyboard.
I do the same in viewWillAppear, and it appears briefly, but then is quickly dismissed.
If I'm on the page with the text field, and pull the page partway and let it go (without changing pages), self.locationQuery receives focus just fine.
It seems like something else is grabbing firstResponder status from the field, but I haven't the faintest idea what, and why it would only be happening when the page changed (rather than revealed after a failed page turn). Any ideas?
Update
I created a way to crawl the views to see if any other views were, indeed, taking firstResponder (from an answer to this question: Get the current first responder without using a private API). Results:
When I explicitly give first responder to the text field, the method reports it has first responder status.
When I don't, it returns null.
Now I'm even more confused.
I don't really understand the nature of what was causing my issue, but I was able to fix it by wrapping the call in an async dispatch in viewDidAppear:
dispatch_async(dispatch_get_main_queue(), ^{
MapManualViewController *strongSelf = weakSelf;
[strongSelf.locationQuery becomeFirstResponder];
});
This one stole a few hours from my life. Here is the Swift 3.x implementation.
DispatchQueue.main.async(execute: {() -> Void in
let strongSelf: MapManualViewController = self
strongSelf. textField.becomeFirstResponder()
})
I also put it in viewDidAppear

Xcode: Reloading a portion of controller with each view

I am working on an IPhone app that, through viewDidLoad, makes a connection and pulls data into a table. I would like the controller, or at least the table, to reload every time the controller is displayed, even if someone just switched from one tab to another or closed and re-opened the app on this controller. Is there a way to do this? I can't seem to find anything, it's also kind of a hard thing to search for. I have found discussions of when to put code in viewDidLoad but not another method that is run every them the controller displays.
Thanks,
Cheryl
You want to use
-(void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
//code to reload table viewdata
}
Each time the view appears this method is called. I use this a lot in my app.
There's no way to do it by injecting code in only one place.
You can think of a workaround, like for example sending custom "reload request" notification from required parts of code:
viewDidAppear: in your view controller
applicationDidBecomeActive: (if table is presented)
tabBarController:didSelectViewController: (if switched onto controller with the table)
tabBar:didSelectItem: (same as above)
etc.
In you view controller simply observe this notification and reload data when required.
Although, whats more important: do you really need to reload data under such harsh requirements? In most cases data reload happens when
view controller's viewDidLoad: is called
it is manually initiated (button, for example)
long time passed since the last update was received
Otherwise it's just an overkill.

changing UIMapView center location works only on second go

I have a pretty simple setup - a tableView that shows my many busStops models (busStop has a coordinate) and When i click a cell it pushes a new VC that shows the busStop's location on a MapView (it sets the map's center to the location of the BusStop coordinate).
For some reason - the first time i press any cell the map is not centered (when i push the "back" button and try again it works).
- (void)viewDidLoad
{
[super viewDidLoad];
[mainMapView addAnnotation:selectedBusStop];
[self updateMapCenter:selectedBusStop.coordinate];
}
i suspect the map is not loaded yet when i try to call the updateMapCenter method. could this be true? what should i do?
i try adding another call from the viewDidAppear and it solved it partly - however this feels like an overkill. any ideas?
I've found that iOS 6 changed the timing for loading the map. I used to set the center coordinate in viewDidLoad, but it sometimes wouldn't work. I moved it to viewWillAppear: and it worked as expected. You might have to think about moving back (as opposed to forward) to the map view, as viewWillAppear: would get called again.
There might be a better way (calling view on the map view?) but I haven't looked into it further.

How do I find out whether my UIActivityIndicatorView is working if the page loads too quickly for it to show up in the first place?

I've set a delegate method that starts animating a UIActivityIndicatorView when a UIWebView starts loading and stops animating it when the UIWebView stops loading. NSLogging shows that both delegate methods are being called (i.e., webViewDidStartLoading and webViewDidFinishLoading).
- (void)webViewDidStartLoad:(UIWebView *)webView{
//start animating
[self.indicator startAnimating];
}
-(void)webViewDidFinishLoad:(UIWebView *)webView{
//finish animating
[self.indicator stopAnimating];
}
The problem is that the page finishes loading before the UIActivityIndicatorView shows up. This means that either a) everything is working fine and my connection is quick enough that the UIActivityIndicatorView doesn't need to show up or b) not everything is working fine.
But how do I tell whether it's a) or b)? Is there a way to slow down my connection artificially?
Tunnel the traffic through a slow proxy, so you will have time to see if the indicator shows up.
One way to do that would be to install Charles Proxy, which has a throttling feature. (And is very convienient for other http-network debugging as well).
The equivalent tool on Windows is Fiddler.
I would comment out your call to stopAnimating and see if your activity indicator view is still spinning. If it is then you know its your request that is super quick.
Or change the URL to load a webpage that you know takes a long time to load and see if you notice any difference.
In my app I simply didn't turn off/stop the activity indicator when loading was done and that showed me it was working then I went back and put in the stop. So if it was replacing a button it will still be showing or if it was in an alertview it will still be up on screen.

tabBarController and first Tab viewDidLoad

I have created a tabBarNavigated Application. In second tab, I do something that works fine, but now I want to do something in the first Tab, so first I try to NSLog a string, but I get no reaction.
- (void)viewDidLoad
{
NSLog(#"Test");
}
If I add a label to the view, it will be displayed, but no reaction on my code.
if I start my app, i see this view, but i can't call any actions in this method, even if i change the tab, and go back to the first one, still no logs.
I try to NSlog in GehaltView
this is the mainWindow
viewWillAppear dosn't work :(
The -viewDidLoad method is only called when your view is loaded. This method will not be called again unless the view gets unloaded, in which case -viewDidUnload will be called. A view can be unloaded if there is a memory issue, but otherwise they generally stick around.
If you want to trigger an action that happens every time the view appears, then you can use the -viewWillAppear: method instead. This method is called every time the view re-appears. You can track when the view disappears with -viewWillDisappear, and watch the two get called as you toggle between the two tabs.
Note also that -viewDidLoad may get called before the view appears, but -viewWillAppear will only be called when the view actually appears (or moments before, as the will indicates).
EDIT: The code should read
-(void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(#"View Will Appear");
}
EDIT: This entire answer assumes that you have a subclass of UIViewController. It seems to me that you are by-passing using viewControllers, which in general is a bad idea.
I found the solution, in interface builder i have to add a custom class to the forst tab.