Cocoa Touch - Alternative to viewDidLoad Method - cocoa-touch

I am creating an app that reads a text file from the web. WHen the app first runs, I want a splash page to be presented with a logo. I have a SplashViewController and a MainController. I am using some code from a tutorial that allows you to add a subview to the MainController's applicationDidFinishLaunching method and replace the main controller's view with the splash screen (follow so far? Trying my best to explain)
The issue I am having is that I want the splash screen to be present until the data is loaded from the web and animate an activity indicator. However, I am retrieving the data from within the viewDidLoad method in the MainController and the app starts retrieving the data before the splash screen loads so there is a delay before the user sees anything.
Is there another method that I can use to begin the retrieval process after the splash has been displayed?

Have you tried -viewDidAppear: instead of -viewDidLoad:? The former is sent when the view has been added to the window whilst the latter is sent when the view has been loaded (from a nib file), i.e., hasn’t been shown yet.

Related

How would I create a loading screen with a start button that leads to the rest of my app?

In my app, I would like a loading screen which has a start button, and when the user presses the start button, it displays my the actual parts of my application.
I can't use a Default.png because i need the functionality of the start button. And since my rootViewController is a tabBar, I can't simply add my screen as a subview, because then my loading screen just appears in each individual tab.
Any ideas?
You could create a new view controller and set that view controller as the root view controller. In the new view controller, create a UIImageView with the loading image and a UIButton where you want it. Then you could go in the storyboards and make the button transition to the "actual parts of [your] application".
Hope this helps!
There are several ways to do it. Assuming your app spends very little time in the Start Screen, I would implement it as a modal view controller that I display over the root tab view.
After you load your root tab bar view for the first time, present the Start Screen view controller without animations.
[tabBarViewController presentViewController:startViewController animated:NO completion:NULL];
If you do this early enough (e.g., in your app delegate's didFinishLaunching: method), the start screen will be the first thing the user sees. It's hard to say exactly where you should insert this code since you haven't said whether you are using storyboards or a default nib or loading a view manually etc.
When the button is pressed, simply dismiss the startViewController.

Rendering a UIWebView before it's parent ViewController is displayed

My iOS/iPhone app starts with a login page (a little like the login page on the Facebook app). There's an info button at the bottom that flips the first view controller onto another that gives a little info about the app to anyone before they login.
What I'm struggling with is that I'm using a UIWebView to display my few paragraphs of body text and a picture, however it's contents is filled in on 'viewDidLoad'. This means that momentarily when I'm 'flipping' between the ViewControllers the info page is blank and only gets filled with my content when the animation is complete.
I have tried setting up the UIWebView inside initWithCoder:(NSCoder *)aDecoder with no luck.
Does anyone have any idea how to render it/have it ready for when it is visible? It looks fine if I leave it and then flip back.
Thanks!
you can "force" the call of the viewDidLoad of the second ViewController in the first with:
[secondViewController view];
with this you can avoid to wait for loading the webview
If I understand this correctly, why not render the second view when the app loads or in the background after the first VC loads and have it hidden, then make it visible it when the user presses the button?
Or maybe just render the webview in the first view controller then pass it to the second view controller when the user presses the button.
Have you tried using the option UIViewAnimationOptionAllowAnimatedContent for the flip animation?

MonoTouch: StoryBoarding - manual segues?

iPhone/iPad dev newb here...
I am using MonoTouch to create a universal iPad/iPhone storyboard app. In the primary view controller (RootViewController) the default auto-generated behavior is a table with a single cell "Detail" in it, which hardwires you to the next destination (DetailViewController).
I'd like to change this RootViewController to instead show a login control I've made extending UIViewController (LoginView). I have had some success putting the LoginView inside the RootViewController, but can't figure out how to make it 'segue' to DetailViewController. And upon watching how the iPad app works, where there is no segue (that I can see) between the two, am I going about this wrong?
To summarize: How do I enhance this storyboard app with a preceding login screen, reusing its contents/xib between the iPad and iPhone variant?
Apologies if this is a bit unclear and muddled.......
I have not tried a storyboard app in Monotouch yet, but I did spend a lot of time working out the best approach for a login screen for my application. What I ended up doing, which could work in your situation as well, is presenting the login screen as a Modal view. Once the user has successfully logged in, we then push the next appropriate view.
So if you are automatically pushed into the detail view by the storyboard viewcontroller, you could display the login dialog as a modal dialog from the detail view's DidLoad or DidAppear methods.

Present modal view controller on top of Quick Look PreviewController results in checkerboard-screen?

Situation: my app needs to present a full screen modal view whenever it becomes active (from background) to ask the user for a PIN. All fine.
Unless: if the user previews a file using QLPreviewController, leaves the app and comes back, the PIN input controller will be presented modally from the QLPreviewController which I'm keeping a reference to. The PIN input is shown but when it dismisses, I see a checkerboard-styled background which is even scrollable. Seems to be some leftover of the PreviewController but the actual preview data is no longer shown. Any idea what could cause that?
Do I have to reload the contents of the preview somehow?
I had similar issue and I've managed to pin down the problem to either viewWillDisappear or viewDidDisappear methods. My solution was to subclass QLPreviewController and overwrite those methods with empty implementation i.e. skipping the call to super. I don't know if it's very safe, though I haven't encountered issues and it solved my problem.

A function called from different class does not work properly

I have a tabbar iPhone application in which tabbar is the root controller and each of the tabs is launching a separate webview window. Each time user taps one of the tabs I intercept the tap in AppDelegate and perform actions, one of which is displaying loading screen (an image in the tabbar view, with display toggled TRUE/FALSE).
My problem is, the loading screen is only displayed when all operations in AppDelegate are finished, which pretty much defeats the purpose of it. My guess is that I did some fundamental error designing this solution, but being a very inexperienced in iPhone programing I don't know how to fix it.
I'm accessing the function showLoading through iboutlets defined in AppDelegate:
[hv showLoading];
And this is what it does:
- (void) showLoading
{
loadingView.hidden = FALSE;
wheelHome.hidden = FALSE;
[wheelHome startAnimating];
NSLog(#"showLoad 1");
}
I'm seeing the "showLoad 1" immediately after bar is tapped, but loading image is only displayed when didSelectViewController exits.
My question - how can I make loading screen appear from AppDelegate OR is there a better way to display loading screen?
The problem is, that the UI is only updated when the event handling code returns to the run loop. You have two options:
Prepare for your long-running task (setup the UI) and then start the task by [myDownloader persormSelector:#selector(download) withObject:nil afterDelay:0];. The benefit of using performSelector:withObject:afterDelay: is that your code returns to the run loop, gets time to update the UI, and then immediately starts the task.
Design your long running tasks (downloading, ...) so that they perform in the background.
First of all, your tabbar should be controller by a UITabBarController and not the app delegate. See the Xcode TabBar template for implementation details.
Secondly, it sounds like you want an Application Startup Image. That is a static image that works like a splash screen if you app takes a little while to startup.