Universal App - restore view state in splitview navigation - xaml

What's the best approach to restore a view "state" when user choose to go back.
For example, a first view "UserList" witch contains a listview of many contacts, and a second view with contact details . How to retrieve the state (including scrollview position etc...) when user back to "UserList" view ?

Finally, the simple way is to use
NavigationCacheMode = NavigationCacheMode.Enabled
in the code behind page.

You should use in the Content of the SplitView a Frame, with that when you go back it will restore the previous content with the same information, I strongly recommend you to take a look to the https://github.com/Microsoft/Windows-universal-samples And look for the example about XAMLNavigation it includes all the matter about navigation.
Apart of course I recommend you to use MVVM and bind all the properties you want to store like the Contacts, etc.

What Juan Pablo is telling you about using MVVM is a good point! Best way is to 'store / cache' the ViewModel when navigating away and retrieving it again when you navigate back.
If you don't want to set the NavigationCacheMode for your view ( because setting this will acquire more memory ), you can use the ListViewPersistenceHelper to retain ListView scroll positions!
An example of that is up on Shawn Skendrot his blog here http://visuallylocated.com/post/2015/07/23/Persist-ListView-scroll-position-without-setting-NavigationCacheMode.aspx

Related

How to structure code with an animation on part of the view

I want to make an iPad app with multiple "forms" that must be filled out. The view has a header and a footer section that are the same on all views. The middle part contains the form fields. I would like the animation between the pages to be only on the middle part. That is: The header and footer must stay in the view while the middle part slides to the next form.
I can create this easily in code, where I configure all fields that must be inserted in the code and then create the animation. However, this feels wrong and not very maintainable. Therefore, I would like to use the story board to configure each of the form pages. The question is: How do I do this? Do I need one or several View Controllers? How do I best create the views and organize the code?
PS. I work on an iOS 5.0 app
The best way I have found out to do this is to create the views in xib-files. Then the view that should be shown next can be generated from the xib-file. All is done in one view controller (since a new view controller would take over the entire screen). This is easily maintainable and easy to animate.

How to create a master view for an iPad app

What I'm looking to do is create some kind of master view, that would have the same header (with a logo), footer (with some text and a button), background image and navigation (not a navigation bar, just a few buttons) on every view.
You could think of what I'm after doing is like a PowerPoint presentation. Create a master slide that's layout is used through every slide, you create a new slide and it takes across all the masters properties (header, footer, background etc) and then it's just the content that changes on each new slide.
However, I'm not too sure how I would do this in an iOS application. I've had a look on Google searching many different phrases but all seem to be about iPad split views and using cells of a tableview, which isn't what I'm after.
All I can think to do is create a single view controller class, with a view, and then add a sub UIView for each page I want (about 15-20), but with the one class, and every page having different content and a lot of code required for each one, that's going to get messy! Or I simply recreate the footer and header etc on every view controller, so if there were to be a change, then I'd have 20 views (more if it grows) to edit! So I'm just wondering if there's a simple way of getting what I'm after.
The app will be for iPad only, and I can use any OS up to 5, so xibs or storyboards are fine. And this won't be on the app store if that helps.
I've done a quick drawing below. The master view with all my bits to be used on each page, and then content slides that will slot in and out of the mater's content area.
Check out Containment View Controllers. This kind of presentation is exactly what they are designed to handle. There is a really nice WWDC presentation from 2012 I believe that illustrates how these work. There are also several tutorials online if you search.
maybe the best option is to create a master detail page. Then for each new page, call the master?
If u want to show header and footer view in whole apps then add header and footer view in window not in view controller i think it will work

How to apply the Theme in iOS Native apps

I am creating a native application in which I want to implement the theme setting.
I have one setting tab where the user can choose any theme.
But when the user select any theme how do I change all the UI, depending on the theme.
1- I have to restart the app from the beginning. When doing this should I use to push user to MainController? And in all the controllers in viewdidLoad I change the theme.
2- Or any other method I have to use please suggest the correct way.
Answer of your question -
1- I have to restart the app from beginning for doing this should i use to push user to MainController. and in all the controllers in viewdidLoad i change the theme.
No. You won't need to do that, as you only have to change look and feel of the app.
2- Or any other method i have to USe Please suggest me what is the correct way.
In Controllers of your app try setting color of elements in viewWillAppear, and all these colours are fetched from NSUserDefaults or any other place from where you want.
When user change theme, just change the color which is stored in NSUserDefaults or any other place, and reload only that controller with the help of utility methods. Rest view controller will automatically gets changes when they will be loaded.
Utility Class will take the responsibility to change the color of UI Element, might be you need to create 2 or 3 utility methods for this purpose.
Hope it clear some doubts.
If you want to re-theme your app depending on what the user selects, I recommend a dynamic styling library like http://nativecss.com/
It let's you retheme your app whilst the app is running, which sounds like what you are after!

Pushing TabBar Controller on Navigation Controller

I am building an app in which at some point I have to show TabBar Controller but my app allready has Navigation Controller, so the most obvious sollution would be to push TabBar onto Navigation.
Apple in it's developer documentation states following:
"You never want to push a tab bar controller onto the navigation stack of a
navigation controller. Doing so creates an unusual situation whereby the tab bar appears only while a specific view controller
is at the top of the navigation stack.
Tab bars are designed to be persistent, and so this transient approach can be confusing to users."
Well I made it this way not knowing about this recomendation :). Now I am wondering if my app could me rejected because of this. Do you have any experiences with this? What do you think aboute this?
I don't think they're going to reject your app (not sure about it, but I don't think anyone can be), but your structure seems very confusing.
have a look at this: iOs Human Interface Guideline
For example:
"Use a tab bar to give users access to different perspectives on the same set of data or different subtasks related to the overall function of your app. When you use a tab bar, follow these guidelines:
Don’t use a tab bar to give users controls that act on elements in the current mode or screen. If you need to provide controls for your users, use a toolbar instead (for usage guidelines, see “Toolbar”).
In general, use a tab bar to organize information at the application level. A tab bar is well-suited for use in the main app view because it’s a good way to flatten your information hierarchy and provide access to several peer information categories or modes at one time."
I think you should transform your tab bar in a tool bar.

Is it possible multiple tab bar controller in an application in objective c

I want to switch different tab bar controller with root view controller's buttons. I mean that I have several buttons and this buttons must have different tab bar controller. Is it possible?
It is possible if you have a navigationcontroller as a parent of both tabbarcontrolllers.
However I would advise against such an UI as it will most likely be confusing to the end user.
Why would you want to use this approach?
have a look at this: iOs Human Interface Guideline
I think that it's not recommended. For example:
Use a tab bar to give users access to different perspectives on the same set of data or different subtasks related to the overall function of your app. When you use a tab bar, follow these guidelines:
Don’t use a tab bar to give users controls that act on elements in the current mode or screen. If you need to provide controls for your users, use a toolbar instead (for usage guidelines, see “Toolbar”).
In general, use a tab bar to organize information at the application level. A tab bar is well-suited for use in the main app view because it’s a good way to flatten your information hierarchy and provide access to several peer information categories or modes at one time.