I am trying to create an array based implementation of Stacks. I am a bit confused with where should the Top Of Stack (a variable in my implementation) be when,
The list is empty
The list is full
The list is neither empty and not full
Please help me out.
Thanks.
That depends only how you define TopOfStack: is it the first unused slot? Or is it the last thing pushed onto the stack.
As soon as you choose one of those two options the rest can be deduced easily.
Related
I need to create a tableview with at least two sections, transportation and hotel. Tapping on either one creates a drop down view showing info on 1 to n examples of the topic selected. You don't know in advance what data is going to be there so it has to be dynamic to present any number of results with some having lengthy descriptions below each example and some not. I've been racking my brain and I can't figure out how to do this. The dynamic nature of this makes it extra difficult. Here is a mock up of what it should look like: click here
Check out this Git-Repo. I am using it inside my app and its working quite well. You can also watch the tutorial for it: https://www.youtube.com/watch?v=22zu-OTS-3M&t=1s
Hope that helps!
This is my first app I am developing for my daughter studies who is in kindergarten and also my first question in stack overflow. Please excuse me if any format issues or if any irrelevance to the forum.
Requirements:
I want a home page (home view) with drop down (or popuplist) with values like
a. Addition
b. Subtraction
c. spellings etc.
and "start test" button on bottom
Based on the drop down list options, I want to display the questions (around 10 questions per category) - "Test view"
It consists of 3 parts
a. example (how to answer the question)
b. question
c. answer area (it can be text field(s) or radio button(s) based on question category in home page.
Results view - After 10 questions are completed, it takes to results screens saying "congrats! your test is completed" (something like this). From there
This is what I have done so far
First of all, I decided to use swift3 to create ios app and I created few png files (for questions) and kept them in assets folder for my use.
I created 3 views and 3 view controllers (home view, test view and results view)
each view has its own separate viewcontroller.swift files assigned
I stored questions in 3 folders (additions, subtraction etc with 1.png, 2.png, 3.png etc)
able to test the app for addition successfully as I placed sample images for additions on my "test" view. For additions, I am able to save questions in questions array and answers in answers array and able to complete the test for 10 questions and able to go to results page and display results. But I am stuck when extending this solution for more question categories like subtractions, spellings etc.
Now my question is
If I want to handle subtraction and spelling, should I create another view for subtraction and another view for spelling? or is there any dynamic way to load the "test" view based on user drop down choice in home page ?
Is there any properties file kind of concept in swift, where I can store the kind of values in drop down list and based on that "test" view will be loaded dynamically with sample questions and answer area (Note: answer area can be input text field or radio button based on question category)
My current idea is to keep adding new view and new view controller when new category of questions are added but I felt this approach is not simple and robust as I need to add/modify the code every single time I add new category. I am trying to find a simple and robust way to handle this use case.
Any ideas would be greatly appreciated.
Question 1:
You should use only one ViewController for all of your types of questions and create the views with the questions via code. To do so you have to add your images to the view.
With an enum list you can identify which questions should be asked:
enum questionType {
case addition
case subtraction
case spelling
}
In TestViewController you have
var type : questionType
Then if you instantinate your TestViewController you can set type and when the view is loading you can show your questions correspondingly. You can also check this var later to handle following processes.
Question 2:
I'm not sure if I understand this question correctly. But I think you are looking for some technic for dropdown-lists? Then you can checkout the UIPickerView class. Here you can add your items and select one of them. You should find some tutorials to implement this in your app.
Question 3:
You're right, creating new view controllers for each of the types is not a very simple solution and would confuse you sooner or later. And because the system is the same for each one it's better to have the code at one place so you only have to do the work one time and not 3 or more times and just add the code to handle new types of questions.
I hope I could help you :)
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.
I use the icarousel class for my project. (This an awesome tool BTW. Thanks to the author.)
I'm trying to reach the following view:
What seems pretty easy. But it is important to keep 2 following items below the current item and just one previously observed by user item on the top. I've reached the similar view pretty easy:
As you can see the order of items is reversed. The view shows one following item below the current item and two previously observed on the top of the view.
Please advise me how to reach effect requested in the first image.
P.S.: Sorry for the links. I do not have enough reputation to post images yet.
I'm making a sample app to learn iOS dev, and I have the app create default items to populate the tableview originally, and you can add further ones as well.
If I tap on the default ones (well, there's only one) and segue to the detail view it shows all the details (Name, Location and Date) as intended. But if I add a new one, it comes up with those fields being Empty.
I can't figure out why. I have seemingly all the view refreshing methods set, and it should be setting the detail view's data object which then feeds the labels.
Could anyone help? I'd supply further code if requested, I just don't know what to supply now as I'm not sure exactly where the problem is. It's a rather simple app, though.
Project available here: http://cl.ly/3N0o272M3y1K
Ok this took a bit longer than planned - but it is a good way to learn.
I have attached the project in a zip file.
The code is a bit different then what you posted, but if you compare them side by side, you will see how they are planned and build differently.
It shows the Segue working within the Storyboard.
There where 2 big problems with your project outside of your misuses of the methods.
You need something like Core Data if you want your data to be persistant. In the example I have given you I have used Plist, this will do the trick, but is not persistant in this case.
Also your detailViewController had no labels for the text to appear, so you will need to look into Custom Cells for that - to match your design.
Good Luck and I hope this is useful:-)
Updated Project