Multiple View Controllers being loaded at the same time. iPhone app - iphone

I am trying to create an app that swipes over through multiple view controllers on a UIScrollView - similar to how one would see different windows in the safari app, but instead of tapping a button to move between them, I am swiping the scroll view.
Now, I will be getting notifications when any of the data in a particular view is to be updated with some json. Should I be updating the view that aren't showing (but are on the scroll view), or should I wait until the user scrolls to that view?
I am very concerned about performance here. Hopefully I am being clear in the question.
Thanks!

You should update the views next to the view that you are viewing I would say. And when you switch (scroll) to another view, then update the views next to that view. (Assuming you have received new JSON data)

Related

Right way to switch between UIViews in ios programming

Hy everybody
I am a newbie ios programmer and I'm facing many doubts when I must switch the pages of my app.
With the term "page" I mean a UIView that fills the whole screen with some widgets (buttons, textboxes. tables..)
As far as I have understood what I've read I should use an UIViewController to manage each of these pages
since each page should be a screen’s worth of content.
My App starts with a ViewScroller with many buttons and when the user clicks one of these it opens a new page.
The first page is the UIView connected to the RootController Of the Window.
So far to open the new pages I add a child controller to the RootController and it's view as a child of the view of the RootController:
RicLocaliController = [[RicercaLocaliViewController alloc] initWithNibName:#"RicercaLocaliViewController" bundle:nil];
[self addChildViewController:RicLocaliController];
[RicLocaliController didMoveToParentViewController:self];
[self.view addSubview:RicLocaliController.view];
RicLocaliController.view.frame = self.view.bounds;
When the user clicks the "Back" Button I remove the child controller and the child view.
Going down this road I would get a dynamic tree of Controllers with their Views.
So far I have not encountered problems and my app can go up to a third level in the tree and come back. Each page behaves correctly when orientation changes.
But I'm afraid that adding, for each subpage, a child controller and a child view could be not the right thing to do.
I'm afraid that if I nest a lot of pages when the orientation changes the app could respond slowly since also the superviews will do something to manage this event.
So what I wonder is if what I am doing is completely senseless, if I should use Navigation controllers or some other way to manage my page changes.
Unfortunately my boss is not giving me enough time to study well the subject and so I would like an advice to follow the best solution possibly using the most standard and less complex component offered by the framework instead of the newest features.
I read a lot of web pages on the subject but it seems to me that there are many ways to manage the navigation beetwen pages and this makes me confused.
I apologize for my bad english but i'm tired and English it's not my first language.
You HAVE to do some studying. You will spend more time clearing up all your problems later otherwise... but, here are some tips.
Using nested ViewControllers leads to all kinds of trouble so if you are short of time, skip that.
Think of each "Page" as one ViewController. A ViewController has a property called View but that is actually just the top view of a whole hierarchy of views. A view is the base class for any visual object, like labels, buttons etc. All views can have subviews, so you can add an image under a label etc. and do really wierd stuff if you want to. I am just saying this to free your mind about how you can use views.
Now, ViewControllers are supposed to hold to code to ONE view hierarchy. That view hierarchy is for that View Controller only.
When the user wants to navigate to another page, you have a few alternatives:
NavigationViewController - that should be used when the user wants to delve down into data, like opening a detailed view of an item in a list etc. The NavigationViewController gives you help with back buttons, proper animation etc. You "pop" a viewcontroller to go back one level. If the user click the back-button, this is automatic.
TabBarViewController - use that if you want a tab bar at the bottom of the screen. Each tab is connected to a ViewController, that has it's own view hierarchy.
PushModal - If you are in a ViewController and just needs to get some data from the user, which is not part of the normal navigation of the app, you can push a new ViewController modally. This is the way you interact with iOS built in ViewControllers. This is also a good way to get a value back from the view controller.
There you have it. Go learn more. :)
It sounds like, for what you are using, you should be using a navigation controller. This will automatically handle pushing views onto the stack and then popping them off again later. This will also automatically create a back button (it is customizable) in the navigation bar.
If you are using iOS 5 or 6, I highly recommend trying out "storyboards" in Interface Builder. Storyboards allow you to graphically represent transitions (called "segues") between different views.
On top of being easier to design and implement, another advantage is that, if in the future you want to change the design of your application, you don't have to trawl through all your code and manually update each view connection.

Loading view in UINavigationController that only appears for a given subview and disappears for others

My application consists of a tabbar controller with several tabs, each with a navigation controller in them. One of these nav controllers contains a table populated via a web service. I'd like to have an overlay on the table (or a different view) that says the service is not reachable if it isn't reachable. However, I only want this overlay on the table, and not on other tabs.
What is the best way to do this? My current solution is a loading view that appears for the table when it appears, or when there is a change in reachability and this loading view disappears on viewdiddissapear. I like being able to put a semi-transparent loading view on top of the table so you can see the old data I guess....
Are there better/alternate ways to do this?
My recommendation is using an activity indicator with a transparent background.
Here is a complete tutorial and sample code (from Jeff LaMarche).
http://iphonedevelopment.blogspot.com/2010_02_01_archive.html

iPhone Loading Popup Scroll Down

is there anyone knows a lib for creating a simple view that scroll down from the top of the screen for "Loading.." message?
Like http://github.com/matej/MBProgressHUD but the view should scroll down when begins to loading and scroll up when finish.
It might seem a little jarring to the user to scroll down and then back up. It shifts the users view of the data down and then back up without user interaction ...
I would simply overlay the loading view ...
Objective C: Adding Loading View to View Controllers
Check the code here: Simple Notifications for iPhone. Sorry for Russian, but the idea should be clear. You just need to add transition from the top of the page when notification label is shown.

how to open a new view whilst keeping an old one visible

I have seen quite a few apps on the app store which display adverts at the top or bottom. I have managed to get adverts to work that is not the problem.
What i was wondering is how do you keep the same advert visible when you load a new view?
I am currently using the present and dismiss modal view functions to navigate through my app.
Thank you,
Mark.
Retain the advertView in a singleton class/AppDelgete (Means Keep this advert view as global and show it on each viewdidLoad) .
You can add the view as a subview of the window. You might have to bring the view to the front. However this approach will need to observe orientation changes and rotate the view appropriately. While this is possible, such a view might make the animations feel odd.

UINavigationController reloading UITableView

In my application I am parsing XML to create a UITableView. When a user selects a row it changes the file that it is parsing and reloads the UITableView.
I want to create a back button so that the user can go back the the previous XML page they were viewing.
In short how can I tell the navigation controller to create a back arrow for this page when all i am doing is reloading my UITableView?
I'd strongly suggest building another controller (i.e. UITableViewController) and push that instead of just reloading the table. This makes the button automagically, and (major plus here), it animates the whole digging down / stepping back in a way that the user is expecting it.
As a side note, I didn't manage to get a back-style button once I tried it, just a plain normal button (make a new button and set it at the navigation bar).
What you're describing is a navigation. Rather than reloading the table's data, simply push a new view controller onto the navigation stack every time a row is tapped. This is a fundamental pattern in iPhone development. Here is Apple sample code for a multi-level drill down table view.