TableView scrolls to bottom and perform some action - iphone

In my application there is a table view.What I want to do is when I scrolls the table view and when it come to its end row I want to perform some action.
Please tell me which approach should I use to do this.
Thanks in advance!!

I think you should make a check in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)
when it loads the last row then call that method.
I think this will work. because table does not load all data at once but i loads data when user scroll

I think (don't the docs up here) but there is no method within the UIScrollViewDelegate that handles the scrolling to the bottom. There is when scrolling to top, but can't remember if there is scrolling to bottom. Check it please.
If not, the easy way is just to check the indexpath.row at cellForRow. If it is your last row, call whatever action you want.

Related

How to implement "Loading" in UITableView when scrolling down?

I am working on iPhone application . This application contains plenty of web services. I need to show list in UITableView with page by page. How to show "Loading" and call web service when scrolling down the UITableview ? Please help me..
I assume that you are adding a custom cell to the bottom of your table view to indicate the end of the current data set. When you create that cell, set its tag property to a meaningful constant you've previously defined, like END_OF_TABLE_CELL.
Then use the delegate method tableView:willDisplayCell:forRowAtIndexPath to check if the cell about to display is your custom cell, and trigger a reload of the table's datasource.
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
//check your cell's tag
if (cell.tag == END_OF_TABLE_CELL) {
//Call your custom method to fetch more data and reload the table
// You should also remove this custom cell from the table and add one at the bottom
}
}
This way you will have a table that refreshes itself whenever a user scrolls down far enough to bring the custom cell into view.
Good Luck!

iPhone TableView When Scrolling Loses User Selection

I am using table view in my app, the task is multiple deletion of cells like iPhone message application. My problem is when select the cells check box and scroll the table then selected cells check marks are deselect. What is the problem?
When you scroll the table then its reload function automatically called. Thats why your selection have cleared. do one thing when you checked your check boxes then stores that values in an array after that call an custom reload function and in that reload your all values in your table...
You need to Manage an array which contain the indexes of the rows for which you select a checkbox.
in cellForRowAtIndexPath: delegate method check whether the row index is in your index array show the checked image otherwise show unchecked image.
UITableView will reuse your tableviewcell, that means it will never keep many cell object, just 5~6 cell maybe. It will save a lot of memory, but it may not keep the state you have set. So you must keep the data by yourself and assign to the cell in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

How to display the selected cell in highlighted state when i come back in UITableView?

I created a custom cell for my table view and for the most part everything seems to be working fine, but when I select one of the rows (which takes me to another UIView), then come back from the subsequent view via the nav controller, the selected cell is not in highlighted state. How to display the selected cell in highlighted state when i come back?
any help is appreciated in advance, thanks.
when you are coming back from anotherview make sure that save the selectedCell and then in viewwillappear method reloaddata.in cellforindexpath write the code of selection style uitableviewcellselectionstyleblue
As #sachin said, you should save selected index path
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.selectedIndexPath = indexPath;
}
and in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
You should check if indexPath is equal to selectedIndexPath,
but you should be aware that Apple discoureges that kind of behavior in HIG: http://developer.apple.com/library/ios/#DOCUMENTATION/UserExperience/Conceptual/MobileHIG/UIElementGuidelines/UIElementGuidelines.html
In rare cases, a row might remain highlighted when secondary details
or controls related to the row item are displayed in the same screen.
However, this is not encouraged because it is difficult to display
simultaneously a list of choices, a selected item, and related details
or controls without creating an uncomfortably crowded layout.

How to reload and animate specific cell in UITableView in iPhone sdk

In my application, I am using tableview with some rows. In each row I am displaying some part
of text.In that row below text there is a Expandbtn. If we click that we will display the whole
text.
For that I want to use reloadRowsAtIndexPaths: WithAnimation: method . I want to apply this
method when I click Expandbtn in each cell.
I am using that above method for expanding text in cell. My Problem If I expand text in first
and go to 2nd cell it appears to be expanding and it is overlaping with first cell.
If I scroll the table to the top, then first cell appears to be NOT Expanding.
Can Anyone Help me in this.
Thanks in Advance.
Relating to "If I scroll the table to the top, then first cell appears to be NOT Expanding." It sounds like you are not dynamically determining the height of the rows.
Are you implementing the delegate method - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath in your NSTableViewController? If so, make sure you are returning a different value before and after you expand the row.

UITableView: delete section controls

Is there a way to add delete controls, like in UITableViewCell, on a table section? I see two ways:
Use table cell instead of sections.
Write own UIView section class, which will show delete controls.
Regarding the first way - as I think, it could be an easiest way in my situation.
The second way may be better from the implementation point of view, but it will take more time.
May be I missed another way? Any suggestions?
The only way I see is to provide your UITableViewController Delegate or Subclass with the method called:
- (UIView *) tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
This gives you the power to display any kind of UIView as a section-header. within this view you can place controls that enable the user to delete sections.
I hope this helps a bit.