iOS Splash Page while Loading Data - ios

I am trying to write an app that displays a simple logo/splash page while the app retrieves some data. I cannot seem to find a tutorial anywhere.
I have a "MainWindow.xib" file that will have my splash page, and I'm setting that as my "Main Interface" in my Info.plist, however, I cannot seem to see how to replace that page with a .xib that contains a UINavigationController. I thought I would just create a new UIController, that had a UINavigationController and in my .xib I'll drag in a Navigation Controller and set all my information, but it's giving me real fits.
So, I figured I would have a UIController that I would "alloc" and "init" with my second .xib that contains all my navigation.
myMainController = [[UIController alloc] initWithNibName:#"MainNavController":nil];
in "MainNavController.xib", I've dragged in a Navigation Controller, but I don't know what to connect it to????
I'm sure I'm going down the wrong, path; but I cannot find a decent tutorial for this.
Can someone give direction or link to a decent tutorial?
Thanks.

Are you ever actually adding the new controller to your existing view? If not, something like:
[self.view addSubview:myMainController.view];
should do it for you. A better alternative is likely to be:
self.window.rootViewController = myMainController;
But I'm fairly new to this and maybe I've missed something ...

To display a splash screen while the app is loading you can use Default.png image file.
However, I think your question is how to display another splash screen for a period of time after the app has been loaded.
In you MainWindow.xib keep your window separated from your Navigation Controller. Add your splash screen view with an image to the xib.
Make two outlets: one for slash view, one for Navigation Controller.
IBOutlet UIView* _spashScreenView;
IBOutlet UINavigationController* _navigationController;
In applicationDidFinishLaunching method add your splash screen view to the window.
[_window addSubview:_spashScreenView];
// lay it out
When you are ready to display your navigation controller:
[_spashScreenView removeFromSuperView];
[_window addSubview:_navigationController];

Related

Loading controller on top of view from storyboard (or nib if necessary)

I've seen lots of topics about this but i could not get this to work as i wanted, i'm sorry that this will look like a duplicate.
What i'm tyring to do :
Show a view from a storyboard VC (or a .xib, it's really up to what's "best") as if it was an alert. The user has to interact with it and then dismiss it.
Here is what i have :
A viewcontroller in my storyboard ; its linked to the corresponding .h and .m files and everything works fine on that side.
Note : That viewcontroller is "alone", there is no segue leading to it.
Now i'm in my active VC from my app flow, and i'm doing this :
ADFViewController *adf = [[ADFViewController alloc]initWithNibName:#"ADFView" bundle:[NSBundle mainBundle]];
adf.xxx = yyy // just setting some data that the user interacts with.
[self.view addSubview:adf.view];
(The VC has a button that does [self.view removeFromSuperview]; to dismiss itself when the user decides to do so.)
I've also tried using this :
adf = [self.storyboard instantiateViewControllerWithIdentifier:#"ADFViewController"];
Both don't work or "almost" work.
They're linked like they should, the storyboard and Nib name corresponds (i've tried both).
As a result I just get a blank screen. The view size is 300x300 so It should at least appear somewhat on my screen. But all i get is a blank screen (the view background).
When that is working, I intend to make the background transparent so it really looks like an alert but i'm not even up to that point. And maybe i'm struggling even though i'm going in the wrong direction.
Questions :
Am i doing something wrong?
Is this the right way of achieving this?
What should I do?
Thanks a lot for your time.
Getting a view to look and behave like an alert (with the transparent background, etc.) takes some work because you can't subclass UIAlertView. I would recommend using an already-built customizable UIAlertView-looking dialogue. There are a couple listed on this question:
UIAlertView addSubview in iOS7
These basically just take a view as input, so you can just pass in your view controller's view and everything else will be taken care of for you.

IOS7: Pop ViewController forces the UIImageView to drop

After upgrading my project to iOS7
when I do a BACK Button and the UINavigationController goes back to the previous page, an ImageView on the top of the screen shifts down.
I use IB to do my layouts. These are my Simulated Metrics:
I have AutoLayout off. Any ideas on what the issue might be? I wasnt sure if anyone wants to see specific code and I didnt want to clutter up the question with too much code.
Updates: Based on the comment questions, I wanted to make these updates:
In no place in the application .h or .m file do I make any changes to the imageview's sizes or location.
In both the viewDidLoad and viewDidAppear I call a user-defined method called recalculateAll but their is no reference at all to any imageview sizes. Just for trying it out I commented out the entire section and ran the code and it still jumps down.
In my init I do programatically set some imageviews (you see the #132 in what appears to be a bubble) using their x and y's.
Here is a typical navigation I use for moving from the view controller to the tableviewcontroller:
GetTimeOffByType *showTimeOffReport = [[GetTimeOffByType alloc] initWithNibName:#"GetTimeOffByType" bundle:nil];
showTimeOffReport.timeOffType = #"Vacation";
[self.navigationController pushViewController:showTimeOffReport animated:YES];
These are all .xib files, no storyboarding at all. Its basically a view controller which has an embedded UINavigationController with 6 buttons. Each time a button is pressed it pushes a UITableViewController passing different parameters and showing different data. The transition I am using to get back to the original UIViewController is simply the iOS generated BACK button (so no code to show for that)
Update#2 Hopefully this will help someone solve this wierd behavior. So if I were to click on the table view cell on showTimeOffReport to get the cell detail and then using BACK navigate all the way back it doesnt jump down.
Update#3 Ok this is something I just discovered : The issue of jumping down or not is related to the translucency of the UINavigationBar. If you have a Translucent = YES it will start from the top of the window. If you have a translucent = NO it will start from the bottom of the UINavigationBar.
You might try setting the new property on UIViewController edgesForExtendedLayout to UIRectEdgeNone.
Here is a good resource that explains more about how view layouts changed in iOS 7.
See Apple Documentation
If you plan to be backwards compatible you will probably need to do some runtime checks and adjust positioning if the device is not running iOS 7.
This might help you..You can try adding UIViewControllerBasedStatusBarAppearance key and set it's value NO in your info.plist
UIViewControllerBasedStatusBarAppearance = NO

iOS version of Fragments

Can anyone tell me what the best way to do the following is in Xcode (iPhone).
I have a main navigation screen with some buttons on it. When the user clicks any of the buttons they are taken to a sub-navigation screen with more option buttons on it. Here they click whichever button and are taken to a list of options. Clicking on any list option will display a screen with some information to the user. Each one of these screen ( no matter what section of the app you're in) will look the same. Only text and images on these screens will change.
I have enclosed a diagram that might explain it better. What is the best way to handle this in Xcode? I have tried doing it all in Stroyboard as I'm new to Objective C but just the sheer amount of individual pages is slowing my machine down to a crawl. So a rethink is required.
I am also doing an Android version of this app and I'm using Fragments for this. Can anyone please help?
EDIT: Just got to my devel machine and this is what I have been doing so far. I realise now this is the complete wrong way to do it. I have created a view controller for each "screen" if you like.
So I just create one view controller for all "screen" of e.g. Individual Page as per diagram and then add the text dynamically depending on what screen is selected? Can anyone point me in the direction of a tutorial or what I need to be searching for? I have no idea where to start with this using Xcode.
If the elements of the view are the same (and only the actual text and images are changing), all you need to do in your storyboard is to create one view controller that will have all these ui elements, from code you can then set it up depending on the content that you want to display in it (depending on what the user clicked in the previous view controller).
EDIT:
Not sure why it was downvoted, but i'll be more clear. Clearly that one view controller is not ALL you need to do in the storyboard. It's all you need to do ON the storyboard related to all the elements called Page in the diagram. Then you would have to link it to a PageViewController class and to all the outlets related to configurable UI elements and in the code of your prepareForSegue: method from the Secondary Nav Screen View Controller you would have to configure it accordingly to what you want to show.
Here you can find a good beginner's tutorial, along with many other good tutorials. What you're probably missing is that you also need to tell the storyboard what class the view controller is and how to connect stuff like labels and imageviews to the actual code so that you can configure them appropriately.
I.E.
From what you're describing, it sounds like you want a UINavigationController as your app's window's rootViewController and to show your screens inside that. You want to create four controller classes:
HMMainScreenController
HMSecondaryScreenController
HMListScreenController
HMPageController
Hopefully it's obvious what would be in each. You'd set up your window in your app delegate like this:
HMMainScreenController *mainController = [[HMMainScreenController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainController];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = navigationController;
[self.window makeKeyAndVisible];
When the user taps a button in your main controller, you'd do this:
HMSecondaryScreenController *secondaryController = [[HMSecondaryScreenController alloc] init];
// configure it appropriately
[self.navigationController pushViewController:secondaryController];
and so on for your list and page controllers.

XCode: MasterDetailsView - DetailsView without Splitscreen in Landscape?

actually I'm quite new with Xcode and couldn't find the answer to the following two questions by a google search:
to make it short: I'm working on an iPad app that displays proposals. For this purpose you should choose a proposal from the table in MasterView and then see the details in the DetailsView in landscape mode (but without the MasterView on the Spitscreen).
So when the app starts in landscape mode, I wanna see directly the first proposal full screen on the DetailsView. And when I tap onto the screen the MasterView should popup/unhide with the other proposals in the table. Is this possible?
I wanna display the PDFs in a WebView like in iBooks. That means that the navigation bar is hidden and only when I tap onto the screen the navigation bar should appear at the top of the screen.
I'm kind of sure this questions have been solved somewhere but I couldn't find anything by search so I hope you can help me anyway :-)
Thanks in Advance!
Q1: Use can use one of many methods to present a view (look up under Apple's doc on UIViewController under "Presenting Another View Controller's Content" heading). Two that I have used are: – presentModalViewController:animated: and – presentViewController:animated:completion: (the latter is the latest addition in iOS 5.0)
So let's say you have a detail controller called MyDetailViewController, in your Master View Controller's implementation file (the .m file), under viewDidLoad method, you would do some thing like this to present it as a full screen view.
MyDetailViewController *myDetailViewController = [[MyDetailViewController alloc] initWithNibName:#"MyDetailViewController" bundle:nil];
[myDetailViewController.view setFrame:CGRectMake(0, 0, 1024, 768)]; //might not need this
[self presentViewController:newDetailViewController animated:YES completion:^{
NSLog(#"complete"); //optional
} ];
To dismiss or hide this MyDetailViewController with a tap or touch, you can use UITapGestureRecognizer or touchesEnded method and using one of the dismiss methods (refer back to Apple's UIViewController again for this).
Q2: I personally have not used UIWebView to display PDF and not sure if iBooks is using UIWebview to do it. But to display a varieties of popular documents formats, you can use either the QLPreviewController class or UIDocumentInteractionController. You can hide the toolbar while the document is displayed.
Good luck.

UITabBar with UITableView - I can see the table correctly, but cannot select a row

This may be an easy answer for someone.
I first built an a navigation app that had a table loaded from SQLite. The rootViewController (UITableViewController) is loaded from the mainWindow.xib . I added the search and scope functions, and push a detailed view (UIViewController) from a row selection just fine, and can navigate back and forth to and from the table and filtered results, search, with scoping different searches. All is good, no errors, crashes, or warnings.
Now I have tried to add a tabBar interface on top of the rootViewController...after 2 days I have got the TabBarController to display (I was trying to implement it directly on the RootviewController, but found I had to implement it in the mainWindow) and I can select different views (xib) from the tab bar. I have one tab that has no view assigned to it in IB, and I can see the RootViewController load as it did before as the first screen in this tab view, even though RootViewController is not assigned in the tab.
The problem is I cannot click on a row in the table when it loads this way. Alternatively if I create a tab, calling the RootViewController, I get the search bar on the top, but the table is empty. I feel this is somehow due to my appDelegate loading the rootViewController, and me not knowing how to get it to "load" or "reload" into the tab, or something like this. I tried creating a separate "search.xib" that was identical to the original mainWindow before adding the tab bar, then trying to load that in the TabItem, so it called the appDelegate first, but no cigar: crash. I verified the search.xib works fine, as I put it as the info.plist "Main nib file base name", and this loads fine and works as before this BS of adding a tabBarController...
I would start pasting code, but not sure what someone would need to know what is missing or wrong. I do call [self.tableView reloadData] in -(void)viewDidLoad, in RootViewController.m but it is not helping this problem at all.
Can anyone help?
Mac OS X is version 10.5.8, and I am using XCode 3.1.4.
// Create and configure the main view controller.
RootViewController *rootViewController = [[RootViewController alloc] initWithNibName:#"RootViewController" bundle:nil];
rootViewController.violinMakers = violinMakers;
[violinMakers release];
// Add create and configure the navigation controller.
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:rootViewController];
self.navController = navigationController;
[navigationController release];
// Configure and show the window, Override point for customization after app launch
[window addSubview:[navController view]];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
Thanks for trying to help!
The last section above appears to be where I should get the RootViewController to be on top of the stack, but not sure how.
// <AppName>AppDelegate.h
#interface <AppName>AppDelegate: NSObject <UIApplicationDelegate,
UITabBarControllerDelegate, UINavigationControllerDelegate>{
UIWindow *window;
UINavigationController *navController;
UITabBarController *tabBarController;
}
#property (nonatomic, retain) IBOutlet UIWindow *window;
#property (nonatomic, retain) IBOutlet UINavigationController *navController;
#property (nonatomic, retain) IBOutlet UITabBarController *tabBarController;
#end
Ben - I do realize what you are saying about the rootViewController being behind the tabBarController. I just don't know how to set the tabBar as the main view, and the navController as a tab of it. I will look at the tutorial you mention and see if that helps explain it. Thanks Ben!
09-10-14 update
Some progress!
I now have the view in the tab with the with the NavBar at the top. I know it is coming from the correct .xib file as the title and the search can now be clicked on, and the scope buttons are the correct names. .... but as before, if I got to this stage or even close, the table information is not loaded into this tab(all cells are blank). How do I get my table to load properly in this cell? I know it is loading on launch, as if there is no view assigned at all to this window, I can see the table n Nav, but cannot click on it.(So close, yet so far away). I now have the tab set up correctly, but the table is not loading properly... rrrr
I have the typical
[self.tableView reloadData];
in the viewController.m in the method:
- (void)viewWillAppear:(BOOL)animated
and in
- (void)viewDidAppear:(BOOL)animated
and in
- (void)viewDidLoad
and tried it some other methods as well, but it is not reloading the table info when I select the tab.
Any ideas on how to reload this table in the TabBar view properly ?
I did find a good tutorial on tabBars that went a bit further than some others in explaining with IB. Twillo Embed Nav in a Tab Tutorial
It would appear that you're adding your tab bar controller on TOP of your table controller. It's not clear where you set up tabBarController, but you should only be adding ONE view to your window (in the third-to-last and second-to-last lines you are adding two).
The basic premise for Navigation and TabBar controllers is that your Tab Bar controller is the primary, and you'll add the Navigation controller as one of its tabs. Then, add the tabBarController.view to your window. Which ever tab is selected will be the visible one.
There's a tutorial posted on the web on this subject.
Basically here is what I have found for those of you with the same problem.
It is not easy, or really suggested by Apple it instantiate a tab bar later in a program. Yes it can be done, but now I would suggest a different method. I found a modal view controller works just a good as a tabBar, abeit smaller, but takes less real-estate, because it can be placed in the navigation bar. If you are planning an app with tabs, start with a tab based app and then customize it, don't try to change the navigation structure later, which is the underlying issue. Secondly I have found Apple's documentation on Interface Builder less than satisfactory. Everyone seams confused and it's implementation limits the actual final product cusomization, not making it easier. Not to mention more confusing on "wiring" all the elements together in it. That really sucks, and I took 2 weeks in trying various methods to make it work. It is not impossible, just incredibly unintuitive, and a mistake on my part to change paddles half way down stream. Look at the alternatives to the way you want to give access to the information, and I think you will find better ways like the modal view to accomplish this, or by simple buttons with IB actions to access different views or further information.
Happy Programming!
Kirk

Resources