How t add new rows atomatically, on scrolling the table view - objective-c

I want to make an application in which I need a functionality of automatic addition on new rows to the table view. say at first the table view has 5 rows in it, after that when I scroll the table then more 5 rows should be added to the end of the table.
please help me!!!!

Hey!! You can try the idea as implemented on following post
http://iphoneappmonster.blogspot.com/2011/04/insert-rows-to-table-view-on-click-of.html

The way you would do this is to implement tableView:willDisplayCell:forRowAtIndexPath in your UITableViewDelegate, and watch for the last row being displayed (using the indexPath argument).
When the last row is about to be displayed, set a flag and call -reloadData on your UITableView. This will force the table view's recalculation, and call your datasource where you should see the flag and add (say) 5 rows to the previous total number of rows (and also clear the flag).
Now, the row that will display will no longer be the last row (it will have 5 rows below it) and presto! Infinitely-scrolling table view.
Keeping track of the total number of rows (and their content) is left as an exercise for the reader.

Related

How can I determine whether a table row immediately follows a page break

Given a Word table which spans several pages, how can my code determine that a table row is the first following an automatic page break? Note that table rows are of different heights thus a solution of the form "every 13th row is the first row on a new page" won't work.
The point of this would be to add extra text in the first cell at the top of every new page.
Use wdActiveEndPageNumber for that table row. Be sure that row is as big as it's going to get before checking the page number.
n = word.ActiveDocument.Tables(a).rows(b).Range.Information(wdActiveEndPageNumber)
If the table is sufficiently large that it splits over several pages then you compare the page number of consecutive rows until the page number changes. There are no pagebreaks to speak of.

Disable autoscroll top on insertRowBefore in a TableView in Appcelerator/Titanium

i'm currently using a TableView to display some elements in Appcelerator/Titanium.
The problem that i have is that when i make a pull to refresh and i call the method "insertRowBefore" to insert new elements at the beginning of the table using the method like following:
$.table.insertRowBefore(0,row);
The table auto scrolls to top, and it looks a little bit bad when there're a lot rows to insert, i want to keep the current position.
Any ideas?
I have had the same problem it looks very ugly when inserting rows at table's top. I have managed this strange behavior by not inserting rows in table directly but inserting them to an array first :
//i suppose that you have an initial array contain your old rows oldRows
//add rows in the top
for(int i=0;i<7;i++)
oldRows.unshift(newRows[i]);
then set table's data
$.table.setData(oldRows);

objective c get first row in uitableview

how do i determine the top row in my uitableview that is currently visible? The table has 200+ rows so when a row is clicked i want to determine the first row number that is currently visible. The idea is that when i go to a detail view page for the table item and come back to the page i can scroll my table exactly to that row ( also my table is all in 1 section if that helps) any help much appreciated
UITableView has a visibleCells method. Check out the documentation. If it's more useful to you, there's also indexPathsForVisibleRows.

Make the first row fixed while scrolling or sorting in NSTableView

I have a NSTableView in I want the the first row to be fixed.
I do not want the first row to be sorted while clicking on the header of any table column. The row should also be fixed while scrolling.
I think there are two ways to go:
Add a proprety to the objects in the tableview. For instance a boolean named 'isFirstRow'. Set this object to YES for the row you want first and add a sortDescriptor based on this property.
(I think this is the most clean solution).
Or remove the row from the tableArray, build the table and add this row back on the first position.

How to prevent only one row to be ordered-obj c

I have a table view. And I have multiple rows. While doing the reorder in editing mode, I want one row to stay in the first index all the time. So, if a user wants to swap a row with the first row, it shouldnt allow it. But it should be possible between the second and the third row.
How can I do this?
Thank you very much in advance
Set the first table view cell's showsReorderControl to NO and return NO in tableView:canMoveRowAtIndexPath: for the first row.
You can also implement the UITableViewDelegate method tableView:targetIndexPathForMoveFromRowAtIndexPath:toProposedIndexPath:
Here you can return an alternate index path if the proposed one is (0, 0).
Return Value
An index-path object locating the desired row destination
for the move operation. Return proposedDestinationIndexPath if that
location is suitable.
Discussion
This method allows customization of the target row for a
particular row as it is being moved up and down a table view. As the
dragged row hovers over a another row, the destination row slides
downward to visually make room for the relocation; this is the
location identified by proposedDestinationIndexPath.