Puzzle tableview with tableviewcell...? - iphone

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

Related

Moving table view cells from one view controller to another

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.

Table not updating when datasource is updated

I have a tab-Bar Controller + UINavigation Controller app.
In tabs 1,2,3 I have table views that offer the user some items to choose from. Once the user selects the items they get added to a Cart.
Tab 4 is a table that shows the items in Cart.
I noticed that when the user selects items in tabs 1 or 2 or 3 they show ip in the cart tab the forst time its clicked on.
If the user then goes back to tabs 1,2,3 and selects more items, the table in the "Cart" tab does not get updated.
Im not sure why this is the case. I have programmed in the "Cell for Row # IndexPath" method to get data from the Datasource each time this method is called.
Im puzzled. Wondering if there is something obvious that Im missing here?
Thanks for your help
The table only updates its data in two situations.
You're using an 'NSFetchedResultsController' to bridge the gap from your data to the view. This controller automatically updates the view whenever the underlying data changes (and, similarly, automatically updates the data when it receives an add/edit/delete request from the view).
You handle it all manually in your own code, most importantly calling the UITableView's reloadData method after the data in the datasource has changed.
you have to reload the data in the table view friend .
[yourtable reloaddata];
use this where you want to show your data

How can I put an editable table view in a tab bar application?

I am starting out with the tab bar application in XCode and I want to put a table view in one of the tabs. I know how to physically put the table view into a tab with interface builder, but I need to be able to edit the data in the table, so I'm not just left with blank cells.
So, how can I edit the data in the table?
Essentially, I want to put a navigation-based application inside the tab of a tab bar application.
Thanks for the help!
UITableViewCells don't, by themselves, support the ability for the user to edit their content. You can set up your UI to allow users to do so, but it'll take a little extra effort.
If what you're really looking for is for the user to be able to enter text into a table cell, I would add an Edit button to your text cells, so that the user can tap it to go into edit mode for a cell.
When a cell goes into edit mode, add a UITextField to the cell view and call its -makeFirstResponder method to bring up the keyboard.
When the user taps the Done button on the keyboard, call -resignFirstResponder on the text field to dismiss the keyboard, then update your table view's data source object (this is the object you've assigned to the UITableView's dataSource property) with the string from the text field's text property and remove the UITextField from your table cell and reload the table's data by calling its reloadData method. Or if you are keeping a reference to the edited table cell somewhere, you could just update the cell object directly instead of calling reloadData on the table.
You can't just add text to table cells in InterfaceBuilder. You'll need to hook your UITableView to a UITableViewDataSource, and have that data source provide the cells you want your table to display.
Here's a great starting point: http://developer.apple.com/library/ios/#documentation/UserExperience/Conceptual/TableView_iPhone/TableViewAPIOverview/TableViewAPIOverview.html%23//apple_ref/doc/uid/TP40007451-CH4-SW2
Give this a shot http://www.amasso.info/?p=77

split UITableView in iPhone

In the amazon iphone app home page there is a grouped table view that has two cells on one row. How can I recreate this?
I would expect, that it is one cell, that shows different information. You can find a lot of informations about customizing UITableViewCells
iPhone Tutorial: Creating a custom Table View Cell
Customize that UIViewCell – Part 1: Using Interface Builder
Go to your interface builder, click on your TableView and press command+1 to bring up the Table View Attributes. There on the first section Table View Style. Change it to "grouped".

How to load a table view when coming to back with out selection index

I am using navigation controller and have table views inside views.
when i select any cell it it will navigate to another view. so,from there if i click back button it come sto previous view.But,it showing the cell which is selected previously. I dnt want this .it should not show which cell we selected previously.
Could any one help me how to get this.
Thanks.
From the apple docs : When the user selects a cell, you should respond by deselecting the previously selected cell (by calling the deselectRowAtIndexPath:animated: method) as well as by performing any appropriate action, such as displaying a detail view.
For more info see http://developer.apple.com/iphone/library/documentation/UserExperience/Conceptual/TableView_iPhone/ManageSelections/ManageSelections.html