I am currently constructing a School schedule app as a beginner project and I could use some help with the final steps. My app essentially consists of two tableview controllers. THe first table contains the student's block schedule (My Schedule). My schedule's table has a dictionary and has keys for each block the student could fill. The second contains a list of all the potential classes a student could take (Class List). All the courses in class list are stored across several arrays. If the student wants to edit their schedule they press an edit button on My Schedule, this produces a "Change" button on every cell in the schedule. What I would like is to create an IBAction that would register the key of the cell that was pressed. Then the app would go over to class list and display all the classes. The user would select a new course and the app would take that course and use it to replace the course in the block that was "changed".
I guess what I really need to know how to do is:
register which cell was chosen
programmatically segue between view controllers
replace a value in a dictionary for a particular key
I realize that this is a lot of info and I apologize if it is confusing or I did not provide enough information. If you would like to see some of my code or need some clarification I would be more than happy to give it.
You can trigger a UIViewController's segue by invoking
[self performSegueWithIdentifier:#"SomeSegueIdentifierProbablySetInIB" sender:self];
Related
I'm brand new to Swift but I want to create an app that has a table and each entry in that table will lead to a new screen (but this new screen is the same for all the table entries) but depending on which table cell you click on, that screen has different information posted on it.
What are the steps I need to do to complete this? I have my story board I'm just not sure how to put this all together with code
Thanks in advance!
Well your question is very broad and not very specific. Therefore it is not easy to give a helpful answer. What I would do:
Create a UITableViewController that holds your "table".
Define a UITableViewControllerDelegate for the UITableView that will be informed about UserInteractions (especially when the user
didSelect a certain row of the table).
Based on the specific row (that was selected) you can create a second UIViewController class the shows your intended information.
I can not show some code samples because your question is to broad and things depend on a lot of things (especially on the kind of data you want to show) and how you implement your UIElements on the ViewControllers in InterfaceBuilder.
And if you are not yet familiar with the concept of a UITableViewController and its Delegate, than you should find some tutorials first about that basic technique in developing iOS apps.
You want to use the master/detail pattern. I suggest doing a search on that.
I am new to programming iOS and I am not sure on how to implement multiple/relational drop down pickers into my design.
I have a search form in my app that works like a panel-menu. If you click on the search icon then the panel slides in with the search form.
But what is the best way to implement multiple/relational drop down pickers for my search form?
The pickers are relational. First you select a state then you must select a city. Once you selected a state in dropdown1 then dropdown2 should get populated depending on what you selected in dropdown1.
So is there any good solution for this when it comes to design?
I would like to show both pickers at all time. Kinda like a datepicker when year / month / day always is shown.
But if anyone has a good resource example on relational pickers please share.
Thanks in advance,
You can set this up with nested UITableViewControllers.
These types of projects are generally called Master/Detail.
The Master tableView would display the list of categories.
Once the user has selected a category, the specific category is passed to the detail View controller. It queries all the subcategories for that category.
This can all by done in Storyboard, using Auto Layout, self-sizing cells, and a combination of show and unwind segues.
A show segue pushes a (table) view controller onto the navigation controller stack. In your case, the category controller would push a subcategory controller. prepareForSegue:sender: is where the category controller would provide the category to the subcategory controller.
An unwind segue returns from a view controller, popping it off the navigation stack. In your case, the subcategory controller would return (with the selected subcategory information) to the category controller, or a previous view controller.
It may sound like a lot to digest, but if you read up on recent (i.e. for iOS 8) walkthroughs which use these concepts, you'll have learned some acceptable practices for how information and control should flow within an app.
There's one more thing I didn't mention, called Core Data. Core Data, and NSFetchedResultsController would be a great tool to learn and use for the app. It's probably more complex than anything I previously mentioned, but once you get a handle on it, you will really appreciate it, and may end up using it in many apps!
Don't get too bogged down with how your app should look. Focus on how the model and view controllers are written, and get a good understanding of the underlying frameworks. That's more important right now, than any fancy transition/animation.
The design of any app will evolve as you use it. You'll discover what works well, and what doesn't, so don't get too attached to any one way of organizing the data!
Hope that helps! Enjoy programming for iOS, it's a great platform!
I am new to iOS app development.
I am developing an app which will show a list of companies.
This list is shown in a UITableviewController.
It has many labels like company name, their field in industry etc.
Once the list is displayed i want to give an option to filter based on their fields i.e.
listing all telecom industry or etc based on my login.
If the user is from a telecom industry i want to show all telecom related companies if user is from a service industry I want to show all service related industry and so on.
I want to give either a drop down on top or buttons or anything that will be easy to see and understand for the user to filter this out.
Please give me an ideas and if possible tutorials to achieve it.
Deeply appreciate your efforts,
Thanks
One way to do this, you can keep all the content in NSArray and you can put a set of buttons or a drop down list ( you can use NIDropDown) if you really want to have a professional look to categorize filters.
User will select any filter from the list and you need to filter the NSArray to extract the required information based on the action performed by the user on drop down list and reload the data in the UITableview.
follow these links to know how to create tables.
http://www.appcoda.com/ios-programming-tutorial-create-a-simple-table-view-app/
http://www.techotopia.com/index.php/Creating_a_Simple_iOS_5_iPhone_Table_View_Application
talking about filters , you can create two view controllers. On first you show all fileds that are present in a table view and user can select by tapping on anyone of them.
use delegate method tableView:didSelectRowAtIndexPath:. inside this method write the code to move to the next screen where details can be shown as per the user's selection.
tableView:didSelectRowAtIndexPath:
{
nextviewController = [secondDetailedView alloc]init];
[self.navigationcontroller pushviewcontroller: nextviewController Animated:Yes ];
}
now obviously you need a navigation controller that can be created in appdelegate method. What data has to be shown on next screen in table is up to you (on user's selection).
In my iOS app, there are various Core Data entities that represent things like Appointments, Notes and Contacts.
I'd like the user to be able to edit selected attributes of each entity via a UITableView. Similar to the iOS Calendar app, when you click 'Edit', you're presented with a UITableView with editable values for Start Time, End Time, etc.
It's occurred to me that there could be a large amount of code re-use going on here, so I'm now considering creating a generic class, ManagedObjectEditorViewController that takes a managed object, displays selected attribute values within a table view, formatted according to their type, and allows them to be edited.
I can think of several neat ways of doing this, but before I spend a long time on this, I'm wondering if there's already something out there to accomplish this task? It seems like such a frequently used approach that I can't believe there isn't already some open source code out there.
Anyone heard of, or used anything similar?
I am about to do the same thing. Just started and works so far. A table that represents an NSManagedObject (Detail to a master view controller, has aspects of a master view controller itself.).
The whole table represents one NSManagedOjbect. There are fields and other controls that correspond with the simple properties.
There are to-one references where the referenced object is just displayed but can be changed.
There are to-one references which are editable NSObjects itself where 1 and exactly 1 of them exists.
There are to-many references which can be added, deleted and edited. Pretty similar to the calendar app or the address book app. (from a functional point of view. It looks different though).
For that I establish a delegate between the table cells and the view controller. This is mainly because I try to stick on the MVC pattern.
E.G. the cell serves as delegate for UITextViews, UITextFields or as target for Buttons etc.
The (Detail-) View controller which owns the NSManagedObject and all related objects serves as my delegate for the cells. It provides methods similar to IBActions to the cells so that the cell can 1) inform about the event and 2) hand over a related view, if required (I need that to display some popups accordingly) and 3) the object itself e.g. the object that is to be deleted or a person-object for which the data is to be fetched from the address book etc.
The View controller can then does its very own duties which is invoking other view controllers (Send Mail, select from Address Book, present a popover with options for the user to choose from, ...).
I just built that up yesterday evening. (It is a free-time project of mine).
I am happy so far but the concept is not really proven yet :) .
What is your current favorite approach?
I have two buttons on a action sheet, when I click one of the button, it will display all the students record in another view. All these records need to be retrieved from DB. Currently I put the logic of retrieve the record in the viewwillAppear method, But after I click the button the screen froze there for a few seconds then the student list will displayed.
Per my understanding my logic of retrieve the record was in viewWillAppear method in student list view. After I click the button , it should to directly to student list view , then in the student list view it will try to load the data. But now after I click the button why it froze in the action sheet? Or are there any other place that I can put the load record logic in so that it will not froze in the previous action sheet After I clicked the button.
If you're going to post to SO, you always should include your existing code. I'd suggest you update your question accordingly. See the FAQ.
When you say that it "froze", do I infer that you're saying that there was a delay before you saw your new view with the data, but that it eventually appeared? If so your task is how to identify where the delay took place. So, I'd suggest you start inserting NSLog statements in the various methods so you can identify where exactly the delay is taking place. Did it take a long time for the new view to be loaded? For the data to be retrieved? Etc. Until you narrow down the problem, identify the source of the delay, you won't be able to solve it. You need to develop the skills to diagnose and troubleshoot your problems. By the way, if you're still having problems figuring out how to diagnose your code and the NSLog doesn't help, you can also refer to Apple's documentation on debugging and stepping through your code. You should only post here after you've narrowed down precisely where in your code the problem is manifesting itself.
Third, most people load their data for their new views in viewDidLoad, not viewWillAppear; if you ever went to a subview of your student list view and then came back to your student list (i.e. the student list view reappeared, i.e. viewWillAppear will trigger again), would you really want to load the data again, even though you've already loaded it? Probably not. I know you might not have another view that you're loading after you load your student list view, but you may eventually (e.g., a student detail view), so good practice is that you should load your view's data in viewDidLoad (which will trigger only the first time the view is initially loaded).