How to create user control [common control] in iOS Xamarin - ios

I want to create a common view / control which will be used in many view controller pages. For e.g. header control which has logo, logout and home button which will be used in many other view controller pages in Xmarin iOS.
Is there any way to create 1 common control / view which I can use any all the pages so if any updates in future, I can change it from 1 page only without updating in all the pages.

Do you mean Custom Controls for iOS? If yes, Xamarin has a couple of articles for that in their guides: explanation and walkthrough. The designer even supports the custom controls which are a subclass of UIView or UIViewController. I guess all information you need should be there.

Related

How to launch a custom UIView as a Dialog iOS

I'm working on a Dialog for my iOS app, and have decided that the default boxes don't allow for the level of customization I am looking for.
So, I have created a view inside a storyboard. It is embedded in a view called DialogBoxView inside DialogLayout.storyboard with a view controller called DialogLayoutViewController.
In short, I want to be able to open the specific view as a Dialog. (Like this below.)
But, as previously mentioned, I want the View inside the Storyboard to inflate as the dialog's layout.
What I need is a way to call into the ViewController handling the Storyboard [I can do this] and open the specific DialogBoxView inside.
See:
My Hierarchy
See:
My Layout
Please note that I have browsed around a bit on Google, and nothing is useful. It is either outdated (OBJ-C) or not what I really need.
Additionally, is it possible just to (like in Android/Java) "inflate" the View layout as the Dialog's view?
Summary:
Can anyone give me an example on how to inflate a specific view (inside a Storyboard) as the dialog programmatically from the ViewController?
I'm still kinda new to Swift and iOS development in general, and I have come across some functions that may work, I just can't put them together in a way that actually works.
NOTE: I have found a way around custom layouts, but am still curious as to how this might work.
Swift 5
Some time ago, I created one project similar: You can see in: https://github.com/MaatheusGois/custom-alert

Swift iOS Application Best Approach - Book With Input

I am attempting to build an application in swift that is essentially a book and some pages of this book allow for user input that is stored in the application.
I am new to swift and am unsure of the best way to approach this problem. So far I have tried using a Page View Controller and separate View Controllers corresponding to each page. The Page View Controller class navigates through the pages using Storyboard IDs to instantiate the View Controllers in an array. This works in creating a navigable book but I run into issues when trying to create outlets from the text fields on some pages since essentially the View Controller is instantiated each time its accessed and so it does not permanently exist.
I am totally and utterly lost as to where I should go from here. Any advice/wisdom will be deeply appreciated.
Thank you
simplest Approach is Collection-view with pagingnation(self.collectionView.pagingEnabled = YES).
https://medium.com/#shaibalassiano/tutorial-horizontal-uicollectionview-with-paging-9421b479ee94
create multiple cell one for your Page(reading) and second for input field.
it also helps for memory management. because cell are reusable. and cell that are visible to Screen are only loaded in memory.
you can also Create Custom layout for animation as per your requirement.

What do you call this stacked folders looking view in iOS?

(source: mshcdn.com)
What is this view called?
Its like stacked folders (Cupertino, New York, Austin, Your Location) that when you touch one.
It enlarges and shows more details, is it complicated to create?
And can someone please show me a link, on how to create one?
Thanks.
It looks a lot like an Accordion.
There are a number of Accordion projects on Cocoa Controls and Cocoapods.
This is just using a UITableView and customising what happens when you tap cells.
You don't need UIKit Dynamics for something like this. Nor would I put multiple UIViews on top of each other as if there are more than a handful you'll run into memory issues.
The transition to the next screen is a custom transition. You can read more about these in WWDC 2013 video. I think it's session 218.
Or possibly in the tech talk videos available from the http://developer.apple.com website.
The iOS weather app uses a similar concept. I'm about 30% through trying to reverse engineer it. I believe it uses a UICollectionView with a layout-to-layout transition.
This is not a standard view controller layout. I think you could call this "Stacked View Controllers", as it is not per se a navigation controller (no push/pop), nor a tab bar controller, nor anything known.

what can be used instead of new uiviewcontrollers

I am developing an iOS app which have 3 main uiviewcontrollers and more than 50 different forms.
I completed designing main forms (login, form selection and message uiviewcontrollers). User will select any form and related form will be loaded. But I do not want to use tab or tableview controller and create more than 50 viewcontrollers in my application. Because all contents are amost same (including a long text and one button).
I would like to create something like subviews (I use usercontrol (ascx) in .net web apps) or or anything else. but do not want to create many viewcontrollers.
What can I use for my forms? Then I will load the content by user selection.
Can you help me?
Thanks for any help.
You could 'group' the forms and see which elements stick together a lot.
Make those subviews of UIView in code and re-use them by adding them programmatically to populate your VC.
From my understanding of your application, you should present your forms as ModalViewControllers. This way you will present the forms when needed and dismiss them once "Submit" is hit for example. Then the form can pass information to its delegate (which can be the main view controller) through a delegate method.
Here's a good tutorial on using ModalViewControllers: "Presenting View Controllers"

Create view from multiple view models

I'm working on figuring out mvvmcross and if I can use it for an iPhone (and eventually iPad and Android) app I'm going to develop. The MVVM pattern is really powerful and works great for me, but I have several views where I need to add a navigation control that will allow the user to jump to several different other views and I'm wondering what's the best way to do it.
Right now, I've created a NavigationControlViewModel which exposes a collection of NavigationLinkViewModel which have a link text property and a command that will show the appropriate view. But to add this to a view for, say, MyViewModel is a little tricky. Right now what I've done is add the NavigationControlViewModel to MyViewModel so that I can bind it in MyView:
private NavigationControlViewModel _nav;
public NavigationControlViewModel Navigation {
get {
_nav = _nav ?? new NavigationControlViewModel (Mvx.Resolve<INavigationService> ());
return _nav;
}
}
This works, but doesn't seem as nicely contained as I'd like to be. I still need to add controls to MyView for the NavigationControlViewModel and then add it to every other view that needs it (as well as adding it to their view models).
What would be the best practice for handling this sort of thing in iOS and MVVM?
I've seen the video on using a split view, but I'm not sure if that's the best approach. I need a vertical split and I only need it on some views, not every view.
For sharing the navigation mechanism between view models, I guess you can use either aggregation as you have done NavigationControlViewModel or you can use inheritance with all the navigation items in a BaseViewModel class.
I personally would happily use either of those but would make sure to expose all my Navigation options as ICommands - simply because that's the way .Net-style data-binding generally expects 'action hooks' to be presented. Note that there is a reflection way of generating ICommand's - see http://slodge.blogspot.co.uk/2013/03/fixing-mvvm-commands-making-hot-tuna.html
For actually presenting the ViewModel via a View on the screen... I'd encourage you to believe that you can do whatever you and your UX/design team want to.
Some of the standard presentation approaches are available via: UINavgiationController, UISplitViewController, UITabBarViewController, UIPopupView and PresentModalViewController - and you are free to use these and to combine them together - e.g. you can have a navigation controller which two layers deep shows a modal view which contains a split view with two children...
Beyond the standard approaches, there are plenty of other UI design paradigms that people have selected:
flyout and flyunder views - like the hamburger menu
the Twitter iPad stacked view approach - like https://github.com/steipete/PSStackedView
heads up display views (dialogs)
continuous scrolled views
... plenty more - see http://pttrns.com/categories/13-navigations
By default, MvvmCross provides you with a 'whole page' presenter which presents every View-ViewModel pair the same way inside a UINavigationController. As you've seen in the N+1 video you mention, you can easily override that behaviour and you can then choose to present View-ViewModel pairs in any way you like - e.g. you can choose to present some whole page, some using a fly out, and then some using tabs.
Because an IMvxTouchView presenter is just C# code, and because we devs love writing C# code, we can implement whatever wonderful logic we want to within a presenter including code that tests what is currently being shown in order to determine where to show the next page.
I can't comment on what 'best practice' is for making a design look nice.
But I do believe that if you stick with showing your view models via ShowViewModel then that will allow you the most flexibility in what presentation strategy to use on each platform.
Some more on presenters is available via http://slodge.blogspot.co.uk/2013/06/presenter-roundup.html

Resources