I've implemented multi selected UITableView.
I want to get multi selected cell informations.
For example, there are 5 cell items in myTableView.
and I touched 3 cell items. and then I want to remove these items.
(It likes multi delete of iPhone mail)
How can i get this information?
This blog goes over it pretty well: http://cocoawithlove.com/2009/01/multiple-row-selection-and-editing-in.html
I won't paste in the code because it is significant, but I'm sure people would like it if you posted your implementation in your question as an edit after you are done.
Related
and sorry for my bad english.
I want to create an app like Facebook that in one tableView there are two types of cells, one for status post and other for photo post.
the issue is that photo post cell and status cell has a different size.
How can i make tableView with two cells that has a different size?
That's how I want it to look:
That's how it look:
You can adjust the cellsize depending on object you want to have inside the cell.
This tutorial is what you are looking for:
http://www.raywenderlich.com/87975/dynamic-table-view-cell-height-ios-8-swift
Another option might be to break your list items into multiple (fixed height) reusable rows.
eg:
#text post:
-Title row
-Text row
-Footer row
#image post:
-Title row
-Photo row
-Footer row
While your table source & delegate may become a bit more complex, this pattern has been proven to scale.
This article explains how facebook did it for android:
https://code.facebook.com/posts/879498888759525/fast-rendering-news-feed-on-android/
I'm trying to create a UITableview that contains STATES and CITIES. To start with, I'd like the table to display only the STATES, with each value having a downward facing disclosure arrow on the right hand side of the cell which lets the user know it has values underneath it. If the user clicks the arrow, the table would expand to show the CITIES associated with the selected STATE. The user could then either select a CITY, or click on a upward facing disclosure arrow which would then "hide" the CITIES.
I've downloaded and reviewed Apples "Table View Animations and Gestures" example.
I was hoping someone might know a simpler way of accomplishing what I'm asking for.
http://developer.apple.com/library/ios/#samplecode/TableViewUpdates/Introduction/Intro.html
Good Job on explaining exactly what you want to do. This is how I would tackle this, I figure it would be easier to explain it without giving you meaningless code and answer any coding concerns you might have after.
I would set up the table view data source to be an array of arrays. The idea would be that every index in the array would represent a state and therefore contain a number of cities, hence ever index contains an array (array of cities). The parent array(of states) will be empty at the beginning, but the arrays(of cities) that will later fill it would be populated with the appropriate cities.
I would then set up the table view to contain sections (I a tempted to put code here, but read along). The sections would represent the cities. You can then fill out the table view with sections using (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section delegate. On the first run you can fill the actual table with one cell per section (maybe with the word "expand" or "more" and your down arrow). When the user touches that cell you can use the didselectrowatindexpath to know which section was touched (the indexpath object contains the section), now that you know which section it is, just modify the data source by adding the array of cities for that section of the array of arrays (parent array) and update the tableview.
This essentially gives your tableview an according style and feel. It is very easy to implement but requires a little bit of code. I have done this and am willing to provide the code you might need, the trickiest part would be to update the tableview in the correct way.
EDIT CODE:
I did a simple example following above explanation. The code is on Github , feel free to ask any questions about it.
I think a better way to represent this information would be to have a UITableView containing the states with each state showing a tiny arrow pointing to the right. Then, when a user clicks on the state, load the next UITableView that shows all of the cities in that particular state. Using a UIViewController for pushing the City list will allow users to easily return to the States list.
This approach will make much more sense to iOS Users, because this is how they expect Tables to work.
There are many tutorials explaining how to use UITableView. Here is a link to a site with many UITableView tutorials. The tutorial I linked to explains pushing a UIViewController on to the stack so that there is a simple back button back to the State list.
Normally such thing is done by seguing to another view and showing more details about cell.
What you want you could achieve by actually making custom UITableViewCell which would contain UIButton with arrow image and UITableView. In case button is clicked for the first time you could reload your cell and create inner UITableView which could show cities. Another click would simply reload cell again and not return inner UITableView at all. You also need to keep selected state somewhere because you may have to reload previous cell and hide inner table in case arrow in other cell is clicked.
This might be really easy to answer but I've searched the net, stack and books but cannot find what I need.
Basically I have a really noddy app with a table, the table has 5 sections and each section has about 5 rows, all I need is for some code to put in the Didselectrow procedure to tell me what cell was selected and then do something -
so if cell 2 then display map etc.
The selected cell is indicated by the index path parameter that you get in -tableView:didSelectRowAtIndexPath:. There's a category on NSIndexPath that gives you -section and -row methods; use those to determine the selected row and then take whatever action ou want based on that.
I've been working successfully with any tableviews. Now I want to display an overview from 1st fetchrequest in the first section of a grouped tableview. In the 2nd section should be shown a list of detailed informations.
Is it possible to display data in one and more data in a another tableview section?
I try to do this with static labels, for better understanding.
Should look like this screenshot - but I am a new user cant post images :(
So I stumbled upon a rather inconvenient 'feature' of the iOS SDK last night, and I wanted to share my finding and solution with you guys. Also to get input, should there be a better solution.
Scenario
I had a table view set up with two sections, on for favorite items another for all other items. Tapping a row in the table view would toggle whether the item is marked as favorite; tapping a row in the favorite items section, would remove it from favorites, while tapping a row in the all other items section would add this item to the favorites.
When the state of favorite is toggled, I use moveRowAtIndexPath:toIndexPath: to do a nice little animation and move the row from favorites section to all others section.
Problem
So, the problem occured because, not only should the user be able to toggle favorite state, also all of the items in the favorites section should be rearrangeable. Thus I wanted to display a rearrange control in each row of the favorite items section.
However, a cell isn't redrawn when invoking moveRowAtIndexPath:toIndexPath: and fromIndexPath and toIndexPath are both in the visible area. This means that the rearrange control is not displayed when adding a new row to the favorite items section.
Solution
After looking through page-after-page in the documentation, thread on StackOverflow and trying out various stuff, I finally found a solution.
Immediately after calling moveRowAtIndexPath:toIndexPath: I also invoke the following lines:
[cell setEditing:NO]
[cell setEditing:YES]
Which would cause that one cell to understand that it's restriction for rearrangement has changed, thus show/hide the rearrange control appropriately.
I find this solution to be very hacky, so I'd be happy to hear about better solutions. But at least, a solution is out here now, for other people to enjoy.