UITableViewCell with custom disclosure causes mis-alignment? - iphone

I hope someone reading this might be able to shed some light on this problem.
I have a plain UITableView containing custom UITableViewCells, each cell is a different height provided by tableView:heightForRowAtIndexPath: and the table does not scroll. The cells themselves are really containers for one or two UILabels nothing very special. Three of the cells show a custom disclosure when editing apart from that no disclosures are used for anything else. The custom disclosures are UIImageView's assigned to the cells editingAccessoryView with 28x29 images however the UIImageView size is set to 40x29 to give a better position using contentMode Left.
This should work fine but what happens is when the disclosures appear in edit mode they don't all share the same position - two might be the same x and the third might be 5px different. This seems to be dependant on the height given to each cell, they basically move around. I can't see how they are associated but have found one set of heights that give the expected results of all three being in the same position. This isnt ideal but has been working fine till now - I have no choice but to change the heights and so the alignment is a big problem.
If I remove the custom disclosures then the standard disclosures work perfectly?
I've tried lot's of things, i.e.
removing the extra width on the UIImageView
reducing the size of the image
playing around with the cell heights - the disclosures just move around
replacing the UIImageView's with other controls - no difference
If you have any ideas why this might be I'd love to here them, thanks.

My guess is its because you are using content mode left in the UIImageView. Use content mode center.
The views get stretched in all directions when the height changes, but the image stays on the left edge of the view...

Related

UITableView scrolls choppy when the UITableViewCell is big

First, I know there are a few answers here on S.O. that addresses the choppy uitableview issue.
Some of them i applied in my code (namely the cell.layer.shouldRasterize = TRUE in particular as well as the cell queue caching thing).
My choppiness is observed to be due to large cell rows (70 pixels height).
If I change the row height to be 20, then it scrolls smooth as butter.
But 30 and above, it gets choppy, especially when i "pull" and "let go" of the table so that it bounces back into place.
One thing that i am NOT doing is flattening the view (I am using the cell's Xib).
Would doing away with the xib design view give me the performance boost that I need?
Also, any ideas why a 30+ pixel height cell row is causing such a drastic difference compared to the smooth-as-butter 20 pixel height?
Note: Even if i make everything in the cell xib to be hidden, i still get choppiness at 70 pixel height.
Check out the example from Apple - TableViewSuite. Look at the fifth example which shows hot to make a very fast cell with images and labels. Also note that cells created using xibs are much slower. So avoid subviews and perform custom drawing in drawRect method. Everything is shown in the apples example:
http://developer.apple.com/library/ios/#samplecode/TableViewSuite/Introduction/Intro.html

Display lines of data with horizontal and vertical scrolling iOS

I wish to display a dynamic set of data (pulled live over a TCP connection) on the iPhone that is not too unlike lines from a terminal.
This means that the lines will be very long and really cannot be wrapped.
What is the best way of accomplishing this?
I want to use a UITableView because then memory issues would be less of a concern because the lines of text would be loaded/unloaded automatically each line of text would be a cell.
I have thought about this a bit and I came up with a possible solution, but I am not sure if it would actually work.
I could put a UITableView in a UIScrollView and only let the containing UIScrollView scroll horizontally.
Then I would adjust the frame of the UITableView and UITableViewCells so that they are much wider as calculated by the longest line of text.
I have read that you really don't want to nest a UITableView in a UIScrollView since UITableView is in fact a subclass of UIScrollView. Since UITableView is a subclass of UIScrollView, is there someway I can enable the horizontal scrolling and make the frame wider?
If either of those ideas would actually work, could you also tell me which properties I should change (frame or contentSize etc).
I ended up putting a UILabel in a UIScrollView and just kept an array of all the lines and made the UILabel the minimum necessary width and height.
I then set the number of lines of the UILabel to the number of elements in the array. This works because there is no textwrapping.
I think this should be fine performance wise, but we'll see.
You can see it in action in my app Adminium for Bukkit/Minecraft:

How Can I Recreate This UITableView Look?

Right now I have a standard UITableView that is empty by default and the user can add cells to it.
I noticed this app starts with no cells and is empty (like you cant see lines) but my standard view always has the lines like standard table view.
I thought it may be a grouped table style but the edges are not curved like the grouped style is.
Does anyone have any ideas?
The lines between cells are controlled by the separatorStyle property of your tableView. To remove the lines simply set:
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Your other options are UITableViewCellSeparatorStyleSingleLine and UITableViewCellSeparatorStyleSingleLineEtched.
You can hide the separator lines by setting their color to the same color as your background, e.g.
tableView.separatorColor = [myApp theColorOfMyBackground]; // A UIColor object
Make sense?
The cells in your picture are likely custom cells, but you didn't really ask about that. :-)
EDIT: As noted in another answer seperatorStyle can be used to simply "turn off" the lines. That's a better way to do it.
This is a good question. +1 What app is this? Does the view you show above actually "scroll" even though only 2 rows are showing? I am wondering if it is a truly a table view. It could be a series of UIViews added to a UIScrollView with a dark background.
Assuming the programmer knows how tall the "rows" are, then they can add them with a pixel spacing over the charcoal background. With the UIScrollView, the programmer can define the contentSize.
If more views were added to extend past off the screen and the contentSize was appropriately defined, the USScrollView would automatically allow scrolling at that point.
Selecting a "row" could be easily handled by UIGesture controls on each UIView.
*EDIT
After seeing the app, Delivery by JuneCload, it is definitely using a UITableView with custom cell views. As Mark and Matt have answered.

iphone uitablecellview overflow

Is there a way to hide the overflow in a UITableViewCell? I have a custom cell view, that I load into the table, where some of the information is supposed to be hidden on load, and then each row will expand when clicked.
Right now, I'm returning height 30 for my row, which is the height of the cell header, but the buttons and text that are supposed to be hidden just overflows and is placed on top of the headers below.
While you can use clip subviews(cell.contentView.clipsToBounds = YES), it's probably best if you add the subviews when you need to expand and remove the subviews the cell collapses. It should increase performance.
There's a property on UIView "clips subviews?".
If you set this value TRUE for the cells, it should stop the buttons from overflowing - you can do it either in IB, or in code programmatically (slightly different name in code).
HOWEVER ... this may NOT be what you want. Depends on the effect. Last time I did what you're doing, I used clipsubviews.
Usually, the correct way to hide your buttons etc is the UIView property "hidden" (or the other one - "enabled").
But that might mess with your animations - depends how you're animating the click-to-expand.

Resize UILabel text with swipe to delete

I am having some trouble getting my application to properly resize the text of UILabels when the user does a swipe to delete or other type of delete. Currently, the delete button is covering up the text that is in the cell (if it is really long). I would like for them to operate like how SMS (move clipped text down a line) or iPod (delete button resizing text).
I am using a custom UITableViewCell I am working with two labels, UIImageView and a couple of subviews for backgroundView and selectedBackgroundView. I have been playing with the springs and struts of the labels in the cell and partially attained my desired effect however, the text has a weird, quick resizing bug where it becomes deformed and stretched out and then is returned proper size when the delete button is done animating.
As far as other things that I have tried, I have made sure that my text does not adjust-to-fit and I have made my minimum font size the font size that I set for the label. I have also tried over-riding layoutSubviews but that didn't seem to have any effect at all.
If a screenshot (of the deforming label) or code would be helpful, I can post both but since nothing I have done is working, I figured they would be of little value.
fixed it by setting the "mode" of the label in the view panel to "left"
It sounds like you need to set the number of lines property and the wrap property for the labels.
If your actively changing the size of the label itself, you might want to animate that change.