Accessory View out of visible range of UITableViewCell - iphone

I create custom UITableViewCell and just put the Accessory Type to Disclosure Button
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
But the half Accessory is out of the View on the right border of the screen.
Sadly, but I can not post a screenshot because I need 10 posts to do that.
I searched everywhere but I did not found anything about this problem.

Since you are not allowed to change the width if UITableViewCell the problem here may be with the width of UITableView itself.
Try adjusting the tableView.frame.size.width to fit the main window/screen width.
You can also check the width of parent views if there are any.

Related

Expanding a UIView in a UITableViewCell as well as the cell itself on click

I have a TableViewCell with three Views. I'm using AutoLayout and UITableViewAutomaticDimension for the rowHeight. What I want to achieve is that when a user clicks on a cell, the blue view as well as the whole TableViewCell gets expanded (animated), like this ...
I couldn't come up with an idea to solve this, does anyone has a hint?

UITableViewCell's detaiTextLabel overlaps with custom subviews

I want to customize UITableViewCell by adding UILabel and two UIButton as its subview.
The cell style will be UITableViewCellStyleSubtitle and these three items would have to
next (on the left) of detailTextLabel.But when i do this, detailTextLabel overlaps with these items and display clipped or partial subviews.
Any way to handle out this without subclassing UITableViewCell if possible.
Thanks.
do you want to display something with detailTextLabel? If not you could try to hide it.
cell.detailTextLabel.hidden = YES;
otherwise you could add another Label at a better position which displays your detailText

UITableViewCells of different heights place their accessoryViews at different X positions

My app has some table cells that vary in height. The cells can also have a UIButton set to be a detail disclosure button (round, blue with arrow) as their accessory view.
Depending on the height of the cell, the accessory view is positioned differently. At first I thought it was my layout code for my cell that was causing the problem, so I set up a quick independent test that uses vanilla UITableCells to remove the possibility that it could be my fault.
I set up a view in interface builder, and just added a view table cells to the view, set their heights to different values and then added a detail disclosure button to each. Nothing more, nothing less.
This is what I see:
UITableViewCells with different x values http://jasarien.com/jing/accessoryView_x_difference.png
I added the size guides (thanks to Xscope) so you can see the difference in the accessory view x positions.
The heights are:
top 37px
mid 68px
bottom 44px (default, untouched height)
If I increase the height any heigher than 68px the accessory view doesn't move any further to the left.
Is this a bug? Is there any way I can prevent this from happening?
Here's the test project to reproduce.
TableViewCellHeightsTest.zip
I got the same problem when I downloaded your file. Instead of setting the detail disclosure buttons manually and assigning them to cells as outlets, delete all disclosure indicators and try setting them this way instead:
Note: I set the background color of the content view to blue for ease of view.
Figure 1 (accessory view height is 17.0)
I was facing this problem and had the luxury of 2 colleagues helping me figure out the cause.
We find out that when using the default UITableViewCell (In my case, of style UITableViewCellStyleDefault though I believe it applies to all other styles), if your accessory view's height is anything above the magic number 16.0, the x position of the accessory view start to differ with the variance of height of the cell.
Figure 2 (accessory view height is 16.0)
My colleague had implemented a custom UITableViewCell and using subviews to layout content and was able to avoid this problem.
So you have 3 options:
Restrict your accessory view's height to 16.0 and below.
Use a custom UITableViewCell and layout your own content as subviews.
Use the default accessory type.
Figure 3 (default accessory type UITableViewCellAccessoryDetailDisclosureButton)
I was having the same issue and fixed it by making the custom accessory view the same height as the cell.

TableViewCells width in iPhone

I'm trying to create a cell on a tableview which doesn't go "all the way" from left-to-right of the screen.
Basically, what I need is a cell which (as usual) starts on the left side of the screen, but with a given width, creating a free space on the right.
Is there any way of doing it? I wasn't able to find any example.
Sorry for the eventually noob question, and many thanks in advance.
In older versions of the SDK this was possible using the initWithFrame:reuseIdentifier:method, however this is deprecated since 3.0, so that you should create the UITableViewCell using the initWithStyle:reuseIdentifier: method.
You can access the frame of the UITableViewCell using the frame property and change it's size:
CGRect frame = cell.frame;
frame.size.width = 123f;
cell.frame = frame;
For indentation on the left side you can simply use the UITableViewDelegate method tableView:indentationLevelForRowAtIndexPath:
You can also add a specific subview to the UITableViewCell on the right side (an accessory view) using the accessoryView property of the cell:
UIView *view = ...
cell.accessoryView = view;
(If the value of this property is not nil, the UITableViewCell class uses the given view for the accessory view in the table view’s normal (default) state; it ignores the value of the accessoryType property. The provided accessory view can be a framework-provided control or label or a custom view. The accessory view appears in the the right side of the cell. UITableViewCell Class Reference)

How to resize a UITableViewCell's accessoryView based on size of cell?

Is it possible for a UITableViewCell's accessory view to be sized based on the size of the UITableViewCell that owns it? How can I achieve this?
Is this a custom accessory view or one of the standard ones? The standard ones only centre in the cell (which is still quite useful) rather than resize. However if you push a UISwitch or other custom view as an accessory view then these might resize.