I have a sectioned UITableView which loads data from a plist file. The table uses custom cells with dynamic height to fit the content of each cell. The table loads just fine initially, but after scrolling down and back up, the cells seem to be overlaying one another in some sections.
I've attached an image illustrating the issue I am having.
http://img20.imageshack.us/i/photo1b.png/
Any ideas on where to begin troubleshooting this problem?
You need to set height for each cell in
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Related
I have a UITableView in which I am displaying bunch of custom cells. The cell is configured to be 50 pixels in height:
I am retuning 50 in the heightForRow method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 50.f
}
But in the end, there's a weird 10-15ish pixel padding/spacing between each cell:
What am i doing wrong?
Thanks!
Without seeing your custom cell's configuration code, I can only guess. The space you see is likely internal to the cell. Perhaps you've added a green subview, but it isn't sized to fit the cell. You probably need to set the subview to have a flexible height (or if you're using Auto Layout, pin the top and bottom to the parent).
Or maybe you have one cell per section and you're somehow creating a blank header or footer.
I wonder which view is used in the next image?
UITableView or UIWebView?
I always wondered how one can tell if a view is embedded inside a web view or not.
Anyway, anyone knows the answer for this specific view?
You can set individual height to individual UITableViewCell using this delegate Method
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
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.
I have created an application in which i have to add users to the sqlite database.
Now the problem is I want the look of the standard iPhone Contact application Where while adding user we have the width of first cell smaller than other cells and the image before that cell..
Can you please give me the idea how such thing is possible.
How to make one cell small and rest others of normal size..
Thanks for any help in advance
There are three UITableViewDelegate messages you can listen for to adjust height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
However, even thought I didn't write Contacts.app I have a feeling they are also using
- (NSInteger)tableView:(UITableView *)tableView indentationLevelForRowAtIndexPath:(NSIndexPath *)indexPath
To adjust the views as well. Remember, you don't have to pack everything into a single monolithic custom table view cell. You can create multiple custom table view cells and load them each appropriately depending on the index path.
The contact detail view is a grouped tableview. Each cluster of cells is a section. The top section is a single custom cell with two subviews that look like squashed tableview cells. The left view shows the contact's photo. The right view shows the name.
To reproduce, create a custom UITableView subclass and lay it out like you want either programmatically or in Interface Builder. Then in the tableview delegate's cellForRowAtIndexPath check indexPath.section and return the proper row for the section.
It appears that the Contacts app uses a custom tableHeaderView when presenting the contact details with an image and label. A similar implementation is included in the sample project iPhoneCoreDataRecipes. The RecipeDetailView loads a separate nib in tableViewHeaderView that is used to set the tableView.tableHeaderView property. Have a look at RecipeDetailViewController.{h,m} and DetailHeaderView.xib. When the Contacts app switches to editing mode, the headerView appears to be swapped out for another view that has a button and a tableView with a single cell. This will allow you to set up a separate tableViewDelegate to handle the Name parts of the contact and a delegate to handle the address / telephony details.
I've seen some applications on the iPhone have an image on top of the tableView, which is straight forward and can be set with something like tableViewHeader.. and a picture below set with tableViewFooter. I recently seen an application where there is an image in the header, a table view, then another image below the footer, and then subsequently a couple UITableViewCells...
Is there a straight forward way to accomplish this without using two UITableViews in the same controller?
Multiple sections will accomplish this, you can also use this method on your UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
in conjunction with a custom UITableView cell created in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
This will allow you to specify a custom cell with the appropriate height that contains your image.
Use 2 sections.