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.
Related
I am working on a app where I want to expand a tableviewcell to cover almost all the screen with animation when it is selected by user. I am looking to create a uiview on the tableviewcell and expend it to cover major portion of the screen when user selects the row.
The main problem I am having is to get the frame from where my pop up view will start expending. How will I get the frame of the row which is touched?
Thanks
Pankaj
Is it crucial that the cell should not reposition?
If not ( i am guessing not, as you are anyway planning to cover whole screen):
When the cell is selected, scroll the cell to top (using scrollToRowAtIndexPath) and either insert your custom view to cell's contentView or modify its parameters if its already there with different opacity/size etc
Use UITableView function to get the rect for the row by passing the its NSIndexPath.
- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath
Is there any way to decrease the standard width of grouped UITableViewCell and put a custom button on the left side(outside of cell boundary)? I tried to change the cell size but it keeps same
You are going to have to fake the editing mode.
What I mean by that is that as AtomRiot said you have to subclass UITableViewCell so that when in editing mode you show the button you want on the left, outside the cell.
But first things first.
To change the indentation level for your cells all you need to do is implement this delegate method for the UITableView
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
So that takes care of it. Then in your UITableViewCell subclass all I would do is to implement the method
- (void)setEditing:(BOOL)editing animated:(BOOL)animated {
which I assume is called when the table the cell belongs to has changed to editing mode.
There I would fade in (or animate in any way you want) a button to appear on the left of your cell.
I have done it inside a grouped-style cell but never on the outside.
Give it a try!
You could subclass UITableCell and add your own custom views inside of it. I have not personally added a button inside one but it should work. It may get confused with the row selected call the tableview makes if you are implementing that.
The Cocoanetics blog seems to have a pretty good solution to this:
http://www.cocoanetics.com/2010/03/how-to-shrink-cells/
I have a view which consists of a tableview and a navigation bar. For my tableview I have implemented a 'Load more' row which will load current + pagesize every time it is clicked
The way the loading works is very simple, every time it is clicked I just request the amount of rows I want to display e.g. 5, 10, 15 and so on. This request populates an array and I call
[self.tableView reloadData]
The issue I am experiencing is that when I go to the tableview the first time, it correctly loads and displays the tableview. However, if I 'Load more' it returns the correct amount and displays the correct number of cells but the last cell will not fit properly at the bottom of the screen, about 1/2 of it (or roughly the size of the navigation bar of the cell) appears below the bottom of the screen.
I thought it was sufficient to just tell the tableview to reload itself. Do I need to use
[self.tableView insertRowsAtIndexPaths ...]
to do this.
Check the frame of your tableview...its probably too big and therefore its getting cut off
After you load more, does your scroll bar stop at the bottom of your table, the way it should work, or does it look like the scrollbar scrolls past the bottom of the table? If the scrollbar scrolls past the bottom of the table, then Daniel is right and your tableView's frame is somehow changing and becoming too large to fit on screen. If the scrollbar stops where it should, then your tableView's frame is fine, but for whatever reason the tableView is not correctly calculating it's own contentSize.
Do you implement this method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
in your tableview's delegate? If so, my guess is you are not specifying the correct size of your table cells. Is the load more cell the same size your other cells?
make sure that your tableview isn't autoresizing...
I have a Table View Controller with cells. I want to update the text that is displayed on the visible UITableViewCells. Is there a way to get a reference to the cells that are currently on the screen?
You can query the visible cells;
[myTableOutlet visibleCells];
Where myTableOutlet refers to your UITableView, and visibleCells returns an array of table cells. You could also use indexPathsForVisibleRows, which will return an array of index paths for the rows that are currently visible.
If you put the code in a ,notification triggered, function, you could update only the currently visible cells.
What you can do is go and ask for the cells at index paths using - (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath, if they are not nil, you know they are on the screen and you can do what you wish with them. Also if you know the visible rectangle on the screen (which shouldnt be hard to get) you can use tableViews - (NSArray *)indexPathsForRowsInRect:(CGRect)rect and you can get all your visible index paths and use cellForRow in order to get the cells back.
As long as this is marked as answer, I stand corrected, like others said you can do [tableView visibleCells]
Call the reloadData method of the UITableView. It will force the table view to update all the visible cells information (check the documentation for more information).
I'm really confused about that;
I have an example view. it contains an UITableview, this tableview contains approximately four or five rows. I don't know am i right or wrong way ? I'm trying that when the user click to the cell the table, i'm trying to add new custom cell onto the clicked cell with animation, this custom cell contains some action and information about the clicked cell. This is actually like to FaceBook start page on the iphone. In Facebook program when the user click to plus icon on the left side of row on start page view, it's working but how.
Can someone provide me an example code or any suggestions ?
Thank you very much.
EDIT :
Guys let me add more detail with some screenshots.
alt text http://img24.imageshack.us/img24/8159/img0398.png
As you can see on this picture, displaying list of data or some think like that.
When the user press the talk balloon (with plus icon) on the right side or per row.
alt text http://img682.imageshack.us/img682/1726/img0399.png
Custom cell or view (whatever) is coming from leftside to onto the selected cell,
with transition.
I think, my question was very clear now.
How can i do that ?
To show plus button in the cell you must set table view's editing property to YES and implement delegate's editingStyleForRowAtIndexPath method - return UITableViewCellEditingStyleInsert for the cell you need.
To add the new cell (with animation) to the table view you must implement
(void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
in your datasource - make necessary changes in your data source (the number of rows in table must be increased by one after this method) and call
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation for your tableview to animate changes.