I need to show a tableview within a cell of a tableView. I have a separate dictionary for tableview that is residing inside each cell of tableView. Where i need to assign the dictionary values to the tableview that is inside the cell
Add the tableView as a subview to the cell. Next assign a delegate/datasource to the tableview. This can be the same object as the outer tableViews datasource/delegate. Every time a delegate method is called, the tableView is send along as a parameter and you can simply do (assuming you have properties for both tableViews):
if (tableView == self.outerTableView){
// ... do stuff for outer tableView
} else if (tableView == self.innerTableView) {
// ... do stuff for inner tableVIew
}
I am assuming here that you have only one cell with one tableView in it. If you have more cells with a tableView in it, the idea can stay the same, except that with many cells with tableViews there is surely a better place to handle the tableViewCallbacks than in the viewController of the outer tableView.
Related
I am using Two UITableview in a single viewcontroller.
When i swipe(swipeleft) a cell in tableview2 that cell gets overlap on the tableview1.
assume the tableview is like
tabelview1||tabelview2 //in single viewcontroler
To establish some context :
I have a UITableView with n cells.
When the user selects a cell they the cell expands and the user experience then continues within that cell.
There are some animations that take place within the cell.
- (void) tableView: (UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath
{
//expand cell/increase cell height animated
//add a button to bottom of cell with target(didpressbutton:)
}
- (void)didpressbutton:(id)sender
{
//perform complex animating rearranging UI elements
}
At the end of the flow the user needs to comeback to the original tableview.
But the cell with the misaligned UI elements are still showing as it is dequeuing the old cells.
Is there any way for me to clear the cached cell or reinitialise them?
But the cell with the misaligned UI elements are still showing as it is dequeuing the old cells.
Is there any way for me to clear the cached cell or reinitialise them?
You are obviously misusing -prepareForReuse:. Implement this method to reset any state the cells have.
In my app, I am using tableview and cell in this which is tableview too. All things work good but when I want to handler selected cell on tableview which is a cell but i don't control
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
}
This function call at tableview parent only. But in my case, i want to call this function in both of tableview (parent tableview and tableview in cell).
Thanks!
Did you imported UITableViewDelegate? and add it to you table view as self.tableView.delegate = self,Better to check once!
Inside the table view of the cell, please set the delegate and datasource as the cell views reference.
As I think, your parent tableView get the select action and block the child table view from receive this action. I think there're two or more approaches to resolve this:
1. Change your view hierachy (contruct) of your view (don't make detail table view as a cell of the parent table). Make the detail table view as top view, so it could received select action, then maybe, pass this action to (parent) tableview.
2. Add UIGestureRecognizer to both child tableView and parent tableView, then check to perform tap action to both of them
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldReceiveTouch:(UITouch *)touch
I got an app with one table. First cell is the coverflow from iCarousel.
When i rotate coverflow and items changed i reload table view:
-(void)carouselDidScroll:(iCarousel *)_carousel{
if (curCategory != _carousel.currentItemIndex)
{
curCategory=(int)_carousel.currentItemIndex;
NSLog(#"%i",curCategory);
[table reloadData];
}
}
But this code drop finger action of rotating. Because first cell with coverflow reload too.
Can i reload table, but dont touch first cell?
You can reload just a range of cells using reloadRowsAtIndexPaths:
It might make more sense to make the carousel be the table header view instead of the first cell though.
I'd like to launch my "add item" form in response to touching an empty cell (the next blank cell), sort of like the stock "Reminders" app. didSelectRowAtIndexPath doesn't work for this and I don't have a clue what does.
Thanks
add a button to the tableFooterView
https://developer.apple.com/library/IOs/#documentation/UIKit/Reference/UITableView_Class/Reference/Reference.html
You could add a tap gesture recognizer to the table view, but be sure to test if the user tapped a table view cell or not.
If you wanna the last cell of your table view to be an add button so that you can add a cell directly without putting the table view in edit mode, then here is what you can do:
For the array you use to populate the table view, always make sure the last cell is a dummy object you use to add a row only.
in your -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath, make sure check whether indexPath.row is equal to [array count], if that's the same, then
insert whatever the object you create to your array at index = [array count]-1.
Call your [tableview reload] method. Then you will see the cell append to the table view.
Hope this helps.