how can i desgin this each layer in single view - ios

This values get from web servies. Totally i want to show 4 layer to display[i show here only 2 layer]. some times in web servies values are come more means the layer become big and show the values.same and anther 3 layers are displayed. help me..!

Use UIScrollView or Freeform make it independent means don't use static value make it dynamic whatever number of layers you are getting from server and according to that adjust content size of UIScrollView.

First of all. This view (and design) doesn't really follow any iOS consistency. The Apple human interface guidelines are there to help you with finding the correct way to do something.
Right...
Do you need to show all the options at the same time? i.e. do you need all four "layers" on the screen at the same time? If so, why? What is the user supposed to do with this screen?
Is the user selecting one option from each layer? Multiple options from each layer? etc...
With either of these I would go down the route of using a navigation controller with a single UITableViewController to display each layer.
So, the user gets a nice list of options...
dumbell
E-Zbar
cable
barbel
...
And selects one (or many) of them.
Then the second "layer" is pushed onto the navigation stack and the user gets another nice list...
incline
decline
close-grip
rotating
...
This way the user has to only concentrate on one task and each list is deployed nicely and readably for them.
If I was a user and was presented with a big list of buttons like your design I wouldn't know what I was supposed to do.

Related

SWIFT: First Time Input / Edit Mode, one screen or two screens?

I've create the following screen which takes 4 inputs when the user creates an account and 'Submits' for the first time.
After they submit once, the screen should go to "edit mode'. My question is, is it more effective to create two view controllers (one for initial input, and the other for edit mode), or just one view controller. If the latter, does anyone have any examples or tutorials? I'm positive that I'm not the first one to attempt this. Thanks!
All you want to do here is toggle the button's title and the editability of the text fields, so it is simplest (and best) to do that in place, in the same view and the same view controller. You are merely changing features of this view, not swapping out this view for another world of interface.

Best practice to have multiple tableviews in a single view controller

This question maybe already asked in stackoverflow. But, I did not get any clear idea to my scenario.
I have a viewcontroller (Say, MyViewController).
I have a scrollview(Say, MyScrollView) and I have N number of views (Say MyView1, MyView2, ...) in it.
Those views can be scrolled horizontally. Refer the below image for more clarification.
This image was taken from here.
So, the red area is the scroll view that holds multiple views which are yellow color.
Scenario:
I want to call API's for each view, when the API calling and parsing data occurs, I need to show some loading activity indicator in the views. After successful parsing, I need to update corresponding view with UITableView.
Questions:
In my case, the number of views may vary from 3 to 6. Should I maintain 6 separate UITableViews and UIActivityIndicator's?
I tried with three pointers like left, middle & right to hold reference of tableview and activity indicator. But the problem is, before the first three pages are loading, if the user goes to the fourth view, this system will collapse with so many conditions.
Suggestions needed. Confused!!
I think you have to use UIPageViewController with UITableView. it will solve your problem.

Making an application like Settings default application - do I need a myriad of view controllers?

I'm making a settings menu in my application, and so far I'm making separate view controller for every screen. Is this a correct way of doing that? It grows very fast, and I am not sure it is an optimal way. For example, I have:
UINavigationViewController that is main controller of settings tab.
Under it I have UITableViewController that shows main settings screen.
When I click any settings cell in the middle, it sends me to its own view controller.
And I need different models to keep every part of every view controller settings separate, or can I just fill them up into one file?
And as I have many customizable settings, do I really need separate view controller for every settings button? This looks overly complicated.
This will depend to some extent on the specific types of settings that you need. For simple on/off settings you can use a UISwitch control directly in your main TableView (see Airplane Mode in the main Settings app as an example).
For any other types of settings that are similar you can use a single generic view controller that is passed the necessary parameters for each setting. For example, maybe you have five different settings that all involve picking one item from a list. These could all call the same controller, passing an array of choices and a reference to the parameter rather than recreating essentially the same view five times.
By doing this and also grouping related settings into a single view (again, see the main Settings app for examples), you should be able to keep the number of necessary controllers to a minimum.
You have options, you can create multiple views and apply a navigation-like push animation varying the view. However, a better way, and where they finally come into use, is using a storyboard.
A storyboard is one file that can hold many view controllers and you can link interactions, it's really hard to use from my experience, but is exactly what you are looking for.

Modal to Double View and NSUserdefaults/CoreData. Where should I begin?

Ok, so this is going to be long, and may be confusing. I am using Xcode 4 w/ iOS SDK 4.3
I will describe my scenario, and what I need. I am fairly new to Objective-C, but I do understand basic concepts etc. I am not asking for someone to do this for me, I am simply asking for some help with how I should go about starting, doing certain things, and making it work smoothly.
I will try and explain what I need in most detail, to prevent confusion. I am truly sorry if this is lengthly, and I appreciate any help what-so-ever. I have been struggling with this for a good week now.
I have a tab-based iPhone application, and the first tab is a Welcome page. I need a first-time use page, which will appear if only it is not filled out.
I will now simply list what I am trying to do.
If the user has not filled out the setup page yet, modally display it after application launch. For simplicity, I will refer to the first"setup" page as "ModalSetup1"
On ModalSetup1, there are 2 segmented controllers, and one switch.
The first has 5 options, and the different options are: 8,9,10,11,12.
The second segmented control has 2 options, they will have text labels, but I am not sure how I am going to implement this (string or int?).
The switch is an optional selection to do another part in the setup. If selected, the "done" button at the top right of the screen will change to a "Next" button, and when you hit Next, it will take you to another part of the setup (ModalSetup2), instead of closing, which it would do if the switch was set to off.
Now, there is another part which might even get more complicated, but I will explain that later (ModalSetup2). I don't even know if you can display 2 different views modally…
What I need is the segmented controller options to be saved, and be able to be retrieved from other tabs/views. The settings won't actually display on the other Views, but it will actually tell the other views to act. Use an "If Statement"?
Now, this part is the next section in the setup. It is "ModalSetup2".
There are 8 buttons, and when each button is hit, I need a picker to be displayed similarly to how a keyboard is displayed. All 8 of these pickers will display the same content, but each is individual as they are each different, and I need a selection from each one. In the pickers, it needs to display 3 columns. Once the user has completed filling out the pickers, they will hit done, and all of the data will be saved, and should be able to be pulled and used in other views of my App.
I am having trouble with pulling the data that is selected (currently saved via NSUserDefaults) and displaying it on another view. Another problem I am having is switching to another view Modally, while still being able to switch back to my original view.
If you need any more info, just let me know. I am adding pictures in right now, so please be patient.

Understanding Model-View-Controller

I have an app where I want to have one “background” view (view controller view), and on top of that, multiple UIViews that draw themselves as circles. I just don't understand how to implement all of this while still adhering to MVC...
The model and the view should be different. Does this mean that I generally need one set of header and implementation files for the view and another (separate) set for the model — even if my object is just a Circle class? Or, would I have one Circle.h and Circle.m set, and then inside the header file have two interface blocks, one for the model and one for the view, and two implementation blocks (again, one for the model and one for the view)?
I’ve seen a few people recommend using the view controller to handle all of the views in loadView, and to avoid creating separate custom view objects; does this mean that I shouldn’t create a separate set of .h and .m files for the view? The latter seems a lot more organized in terms of design to me.
Also, if I were to have multiple view objects and multiple model objects handled by the view controller, I would store these in two arrays in the controller — one for models, and another for views. Right? My question is: When I use key-value observing on each model, how would I, for each model object, alter the correct corresponding view object (assuming that indexes are not the same for both objects in both arrays)?
I was thinking about using a pointer to the model object inside of the view, and KVOing from the view to the model — but then it doesn’t go through the controller and thus breaks MVC altogether, right?
Thank you in advance.
MVC is a big, broad idea. It's more a guiding philosophy than a specific rule, and it's not always implemented the same way. Read Apple's discussion of MVC to appreciate the difference between traditional MVC and MVC in Cocoa.
It's hard to say how to apply MVC to your app because you haven't told us what the app should do, and also it doesn't sound like a realistic application. So I'll do my best here and make some assumptions along the way. An app that just draws a bunch of circles in fixed locations on a background isn't very interesting -- it could be almost all views, barely any need for a controller at all. So lets say that the circles are all moving in different directions, are drawn in different colors, and change in size over time. Now you start to have a need for a model, so that you can keep track of the data that these circles represent, and a controller to translate the model into terms that can be represented by the views.
Since you asked specifically about drawing circles, lets start with the view. It seems like a good idea to have a custom view that knows how to draw a circle given the necessary parameters: area, color, and position. You'd probably make these things properties, and override -drawRect: such that it draws a circle of the given area in the given color.
We don't know what these circles represent, but it's not much fun if they don't represent something, so let's postulate that the app's job is to help us compare corporations. We have data on revenue, market capitalization, number of employees, credit rating, name, ticker, etc. You could create a custom object to store all the data for each corporation, or you could put it all in a dictionary. Our model is a set of these custom objects or dictionaries.
Notice that the circle views don't know anything about corporations, and the model doesn't know anything about circles. This is A Good Thing. It's also where the controller comes in. The controller is where you put the code that expresses the model visually using the views. It also interprets events from the views, updating the model as necessary. So, our controller knows both about the particulars of the corporations, and the properties of the circle view. It creates a circle view for each corporation in the model. I want the area of a circle to correspond to the corporation's market cap, the vertical position to represent the revenue, and the horizontal position to indicate number of employees. We'll assign a color based on the corporation's credit rating. The controller should, of course, keep track of all the circle views and some way to map between circle views and corporations.
Now you've got something. It's still a pretty simple application, but you've got a useful chart comparing corporations in several dimensions. Let's improve it.
First, it's hard to know which circle represents which corporation. It would be nice if a circle view could optionally display some text. Let's add title and subtitle properties, and modify -drawRect: to draw these strings above and below the circle, respectively. We'll also change the controller so that a tap or click on a circle sets the title and subtitle of that circle to it's corporation's name and ticker symbol, or clears them if they were previously set.
Second, it's nice to compare corporations at a moment in time, but more interesting if we can show changes over time. Let's change the model to include historical data for revenue, market cap, employees, and rating. We can update the controller so that it can uses the historical data to animate the circles.
The first change related to how we draw information on the screen, and didn't require any modification to the model at all. The second change was about what data we have to work with, and didn't require any change to the view at all. You could easily re-use the circle view to represent some other kind of data, or maybe even to be the puck in an air hockey game. It's just a colored circle. And you could re-use the model in another app that deals with the same kind of data.
I'm sure the hypothetical application in this very long-winded explanation-by-example bears roughly zero resemblance to your own application, but perhaps it'll help to explain why MVC is useful and inform the structure of your own application. Good luck.
I got good explanation from CS193P IPHONE APPLICATION DEVELOPMENT (Winter 2013).
Model-View-controller:
Divide all objects into three camps:
Model : What your application is (A Card , A Deck , card game logic)
Controller : How your model is presented to user (UI Logic). Controller knows everything about the UI.
View : Your controller's minions.
How those camp communicate :
Don't cross yellow line.
You can cross over Dashed white line.
some special rules are there for crossing solid white line.
Controller --> View (via Outlet)
View --> Controller (via Data source (count, dataAt), delegate(will, should, did), Target-action)
Model --> Contoller (via Notification & Key Value Observing)

Resources