Load different views after rotation - uiview

I have a view controller which contains a ScrollView and an array of views on that. When i rotate the device a strange situation happens with the frames of my view. I googled and Stackoverflow'd, i need to use two different .xib files but i have no idea about how to do. Can any one share some opinion-or link to tutorial please?
My app is Web-Service application and the information comes from a web server. I tried to create two different .xib files and display them differently but it is too much coplicated(or comes so to me). Please, just a link or an idea wwill be great helper

Related

What is the general structure when coding an iOS project if there is any?

So a few weeks ago I got into Swift and before that I learned a bit Web dev. When learning web development there was always a certain structure to follow for any project. Like specifying where to get the stylesheet from, where to get the JS and that information was put into the head of an html. It is not easy to put my question into words, but is there a general structure for iOS projects? So far I realized that there is always an "import" for example at the beginning of any file to add a framework and then a class. But there is always just one class and all the code goes into that class, why? What else stays always the same for iOS projects?
There are a couple of ways you can approach developing an iOS project. But generally this is what you need to know.
All your UI related designs can be implemented in Main.storyboard file in your project. Here you can create a View Controller and add various UI elements to them like button, labels etc.
To make sure your views look the same across all device screen sizes, you need to use autolayouts which is the process of setting constraints to the UI elements so that they can be resized according to the screen size of the device they are being displayed on.
For each View Controller created you have to assign a class file which is a .swift file. In this class file you have a function by default called viewDidLoad(). This method is executed when the view is displayed on the screen after running the code.
For each UI element in a View Controller you can add IBOutlets and IBAction to their respective class file.
Here are a few links that can help you more:
Tutorial for autolayouts: https://www.raywenderlich.com/443-auto-layout-tutorial-in-ios-11-getting-started
Tutorial for Swift programming: https://www.raywenderlich.com/6338-swift-tutorial-part-1-expressions-variables-and-constants
Get started with iOS: https://codewithchris.com/how-to-make-an-iphone-app/
Some other useful links:
https://medium.com/ios-os-x-development/7-things-you-must-absolutely-do-before-writing-an-ios-app-a8bacf710c57
https://www.raywenderlich.com/477-design-patterns-on-ios-using-swift-part-1-2

ios - how to create a screen with a lot of text and buttons and not use UIWebView

I can not use UIWebView because I want the text to be accessible even if the user does not have Internet access on their phone. Also, I will need to have buttons to other screens on the app and I think that is not possible with UIWebView (right?)
Is there a way for me to edit the xml of the screen directly inside Xcode? My requirement is to have about 10 sections with header labels and buttons before each, so if I have to adjust it on the storyboard screen, it will be a bit nightmarish.
What is a reasonable approach for me here? I think only to edit the xml by hand and hardcode it with styles and text, right?
several things here:
webviews only need an internet connection if you are downloading the content for the view (which doesnt seem like what you want anyway, aren't you just building it locally?)
you can make the buttons in a webview do whatever you want. See this answer.
What is so complex about this UI that you can't just build it the regular way in code or IB?
Just because you consider using a UIWebView it doesn't mean you are restricting your application functionality to internet access.
You can just as well have HTML documents in the application bundle that you display in a webview. This is basically what PhoneGap is doing.
If you don't want to use webviews then nothing is stopping you from using UIViews, UILabels, UIImageViews etc and compose your app how you want.

Reusing Views ios

Trying to develop a test app wherethe look is like ebook. user can flip the pages. However, app will have 40-50 pages to go through. Is there anyway to just update one view and even after re using you can easily turn it over and back. or do I have to create more views to achieve objective.
Can someone pls provide suggestion on which technique to use to solve this issue and also what to use for flipping like ebook?
Since you have tagged your question with iOS5 you can use a UIPageViewController (see also this one) to handle this behavior for you (datasource handling, gesture handling etc.). The logic behind it is that you provide an array of view controllers where each one controls and provides content for a page in your book.
One way is, please look in to "page base application". Please create a new project as page base application and work on that. You will find good amount of documentation online for this.

iPad ViewController configuration for document-based app

I was wondering what would be the best configuration of view controllers and views for an app that I’ve been planning out. Conceptually, the way I would like to lay out the app is with an initial loader/browser view, likely with document thumbnails. When a user chooses to open one, a new view comes up that forms the main document-editing mode. The user can also choose to bring up a third view that contains an alternative document-editing mode.
I suppose this is very much like the way the Pages for iPad works, with first a row of document thumbnails to choose from, then the main word processing view, and accessible from a popover a third page setup view. Document browser view, and two document editing views.
Now, I can think of, and have been playing around with a few different set-ups, but in each case I can see problems that I’ll be running into later. So really, I’m looking for advice on a configuration that you think would keep things as neat and manageable as possible.
I hope this is not too open a question, and I would very much appreciate any answer.
Thank you,
I will probibly get shot in the head for making a suggeston like this, but I'll make it anyway:
In learning iOS programming, I spent a lot of time studying (as most people do - and as is taught by every tutorial on the planet) on how to use Navigation Views, and toolbars, and all the standard type views that assist in different types of navigation.
On the latest app I have been working on - I spent a lot of time and frustration trying to figure out how to best characterize what I was doing - and moreso trying to fit it into what the iOS frameworks would use to implement this stuff. Then (of course) I got stuck trying get things to do what they weren't supposed to - like when a navigation view wouldn't let me use the "back" button to jump out of the navigation herirarchy I'd set-up, etc.
In short - when I stopped worrying about the specifics of what all these different types of views and controllers were - and how they interacted and how I was supposed to do it - and started worrying about how I wanted my application to work - and working from a basis of generic views, custom toolbars, etc - the whole think made a whole lot more sense.
In my case, I liked the look-and-feel of the Mapquest app - and they way it dealt with toolbars that your could open and close from the top and bottom of the screen - which had buttons - which could switch to other views etc. So I started using "generic" views to implement this functionality - and the whole entire thing clicked together.
So in-short:
1 . I'd decide how you want it to look and what you want it to do
Use a third-party app as your inspiration, if needed
Decide when/where/if some of the "standard" practices apply - and use them where/when they do.
Have fun!
-BKG

use multiple views in an application

I am new to Iphone programming. So please don't mind if I ask some basic questions. :mad:
I want to develop an application where the landing screen will be a login screen and after login application should display a new screen with the list of available categories. And on selecting any category a new screen should appear with the information related to the selected category.
Basically I want to display different screens in the applications and my confusion is how can I make different screens with one .xib file? or should I use different .xib files for each screen. If I use different .xib files for each screen then how should I navigate to different screens.
Please help in solving this confusion.
Thanks in advance
Gaurav
You should definitely use different .xib's for each view. You will end up having a standard view, a table view (probably programatically wrapped in a navigation controller) and a standard view, respectively. Each will also have their own class.
You navigate to different screens by programmatically initializing them. The condition on which they are created varies from screen to screen. For example, your login screen will only create and load a table view for the categories after a successful login. The category screen will only create a detail screen when the user touches a category in the table.
I think your best bet is to pick up an iPhone programming book and do the first few chapters until you feel comfortable with the basics of XCode. The Apple documentation usually contains more than you really need to know and by the sounds of it, you just want to jump in and make a few simple apps.
After that, you can look at the Apple sample code here: http://developer.apple.com/iphone/library/navigation/index.html#section=Resource%20Types&topic=Sample%20Code

Resources