Using UITableView, I can display a list of items using an array in rootViewTabel, how can I display another list in the nextView of the table?
My first view displays a list of months from jan - dec.
On selecting a particular month I want to display the list of festivals for that month in the same table.
What code should I include?
When the app launches use your root view controller to display the list of months. When the user taps on a particular cell, push another view controller which will in turn display the list of festivals for the selected month.
Following this way would be very easy to learn and implement.
Here are a few links that will help you learn and implement it easily.
Easy custom UITableView drawing
iPhone Programming Tutorial – Populating UITableView With An NSArray
So go ahead and code...
Related
I am new to stack overflow and a student currently learning objective-C at university. I am building an APP for the science museum in London and I'm creating an events planner.
I have two table views set up in two different View Controllers.
The first View controller and table view is called "Events" and it holds all of the current days events. When you click on an event, it goes into a new View Controller, gives more information about the event and has a button to "Add To Events", which pops up an alert saying: "Are you sure you want to add this to your events?" with an add button and dismiss button accordingly.
The information in this table view is populated using three NSMutableArray's. (One for title, subtitle and image).
The second view controller has an empty table view inside it. I am trying to make it so whenever a user finds an event they like, they can click into it, see more info and if they want to add it to their own events page, they can. I have got the "Add" button of the alert responding using an NSLog message, so the code to implement the adding to events would go there.
My question is, if i click on the first event, and then choose to add it to my events, how do i send the information of that specific tableviewcell that i clicked to display in the second view controllers table view ?
I have looked all over the place for information regarding this and have taken an abundance of Lynda courses online about IOS and objective-C, but I haven't been able to figure it all out.
Can anybody help?
First of all you shouldn't use three NSMutableArray's to populate your cells. Create one NSMutableArray and populate it with NSDictionarys with a key for the title, the subtitle and the image. Or even better: create a custom model (subclass of NSObject) for your Events and populate the NSMutableArray with those.
Now just like your NSMutableArray is the data source for your first table view controller you need another NSMutableArray as the data source for the second table view controller. When a user now clicks on "Add To Events" all you have to do is add the Event (Model or Dictionary) to the NSMutableArray of the second table view controller and either call - (void)reloadData on your table view so that it reloads ALL data or use the "Inserting, Deleting, and Moving Rows and Sections" methods from the UITableView Class Reference. This would be the better approach because it does not reload data that does not need to be reloaded.
I am developing an iphone app for a class project and am displaying a bunch of different products. I am trying to create a favorites page where users can add one of the products to their favorites page. The app is set up with a bunch of different tableviews to display the different products along with their piture, name, price, and description. I want the user to either click on my addtofavorites button I will add to each of the table view cells or I was wandering if I can just use the didSelectRowAtIndexPath method in the tableviews to add all that information to the favorites table view. Thank you
First, look into following the MVC pattern,
a good introduction: https://developer.apple.com/library/mac/#documentation/General/Conceptual/DevPedia-CocoaCore/MVC.html
That being said, I'd have a products UITableView, in a view controller. The user can then select the view controller and in the didSelectRow: method, find out which product was selected to sou can pass the data through a delegate patterns (other ways include target-action, NSNotification, etc.) for example like this: (good example of passing data: Passing Data between View Controllers) to a separate view controller which would hold your favorites table view. Make sure the model is separate from both the products view controller and favorites view controller so you can save all the name, price, etc whatever properties you want to save.
perhaps all of this would be contained in a UITabBarController so it's easier for the user to go back and forth between products and favorites.
I need a bit of help on a app i'm developing.
The app is containing two tableviews (two different xib files with view controllers), named RootViewController and addFavorite. Both of them has the subclass "UITableViewController".
The first uses CoreData to save the users favorites.
The other one collects a list of data from a txt file on the internet.
I know how to set them up seperatly, but I'm trying to make a app where you add cells to the coredata-list from the tablev nr. 2. The user should - when clicking on the "add cell" button in view one, be redirected to view 2, where the user selects a cell, wich is being added to the tableview nr. 1, and then is being stored in the core data.
Why not just refactor you code a bit to abstract the data out into an NSMutableArray and populate your UI from that?
I have a small query.I have made an application in which i am fetching information from the webservice and i am displaying it on the table view.The table view which i a using is customized one in which i have used the text and the image property.
These things are working fine but now i have added a button ,once i click on it then a new view appears which has 2 options for 2 countries whose webservices are provided to me ,once i click on one button and see the table view then the list of the previous table view only appears and if i scroll through the whole list then the values changes which is according to the webservice.
So kindly suggest me as in what should be the approach of directly showing the updated tablecells.
[tableView reloadData];
call it explicitly from the secon view, or you can put it in viewWillAppear
I'm in the process of learning and designing an app for our company. At its heart, it has a list of "alarms" which when clicked on, goes to a more detailed view with a toolbar to perform tasks upon that "alarm".
I'm having a devil of a time working out how to structure this application. I have something that works currently (i'll explain it in a sec), but now I'm about to hook up the data source for the table and I'm getting myself lost.
At the main screen, there is to be a list of "alarms". This list should be able to be filtered with 3 categories (All, Category 1, Category 2) where the categories are subsets of all the "alarms". I've implemented this using a TabBarController.
Within each tab, I've got a NavigationController (to handle the navigation of between the list and the details) and it's main view is a custom UITableViewController that contains the custom table view.
As described, when you click a item, it navigates to a detailed view. This is all currently working but I'm concerned about the structure.
It's pretty obvious that I have a fair bit of duplication with the 3 different NavigationControllers, but I've read that subclassing the NavigationController is not recommened.
My questions are:
Is there a better way to structure this application? Is there a better filtering method (thats quick and easy) instead of a TabBar?
Where should the tableview datasource go? Most examples I've seen have it being created in the AppDelegate and then passed directly to the tableviewcontroller. My custom tabelviewcontroller is a couple of levels down the controller chain, how do I pass the datasource to it, or can I make the datasource "static"?
I hope that all made sense
Sounds as though you want one navigation controller and table view controller with a segmented control at the top to switch between the different data views. For an example of this kind of layout have a look at how the App Store app works when you select the Featured tab - it has a segmented control to switch between New, What's Hot and Genius.