How to increase area that allows tapping on tableviewcell image? - iphone

I have a tableview cell with a custom image in the imageview of the cell. However, sometimes if you tap on the image (a checkbox), it taps on the actual cell instead of the image. I want to make it so if you tap part of the cell around the image, the checkbox is checked instead of the actual cell. How would I do this?
This is some code..
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
cell.imageView.image = [UIImage imageNamed:#"unchecked.png"];
The image is a 28x28 image.

One simple way to solve this is to increase the width of the cell's image view.

Probably the easiest way would be to create UITapGestureRecognizer and add it to cell.contentView using the same selector you are using for image tapping.

Related

Set Cell Subview Position After Height Set?

In my app I have a tableview, with a custom tableviewcell and that has a UIImageView in it.
However, my issue. - (void)configureCell:(MyCustomCell *)cell atIndexPath:(NSIndexPath *)indexPathwhere I set the frame of my image is called before - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath where I set the cell height.
Meaning, the image position isn't correct (its dynamic, changes depending on cell height).
How do you suggest I get around this?
Thanks.
When do you call your configureCell:atIndexPath: method? In your tableView:cellForRowAtIndexPath: implementation?
Anyway, try to set you image height in tableView:willDisplayCell: delegate method instead. This method is called just bore the cell is displayed on screen so that it will not be resized afterwards by other internal methods.
Besides, can't you use the AutoresizingMask property to make your image view resize automatically depending on its container view (the cell)?

UITableviewcell spacing between cells

I am creating UITableView cells dynamically and adding three labels on to it.I made my table as transparent by opaque no and clearcolor.
But the cells are being shown without spaces.I need to give space between cells.
Actually if i load a custom UITableViewCell from the xib file the space comes automatically. How to solve this issue?
UITableView with custom spacing
You can do this by cheating the tableView cell. By default you can only specify a single line, etched line or none so here is an alternative. You'll need to override the tableView delegate method:
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
Calculate your cell height with its contents, margin/padding/line width and return it. Set the background color of the cell to [UIColor clearColor] and make your table background the desired color for your separator. Subclass UITableViewCell and attach a backgroundContainerView and make it the desired background color for your cell. Attach all the subview to that backgroundContainerView.
Finally, in the UITableViewCell subclass implement
- (void)layoutSubviews
Here you should layout the subviews with the container view as if that is the whole cell.
In UITableView you have 2 properties : separatorStyle and separatorColor. Use them maybe your separator color is clearcolor so try and change it.
This problem is due to the difference in height in TableView and Custom cell. Set the cell height in heightForRowAtIndexPath delegate.

Changing grouped tables border radius

Is it possible to change how radius of the grouped UITableView? The rounded corners are way to drastic for my design.
I believe that the only way to do this is to provide your own background images for your table cells. You can provide 3 images to have a rounded feel to the UITableView like Apple Does.
in
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
set the cell's backgroundView to a UIView with the image you want based on the cell index. This will allow you to set the Top, Middle and Bottom.
This is a pretty good article
http://cocoawithlove.com/2009/04/easy-custom-uitableview-drawing.html
just be sure to dequeueReusableCellWithIdentifier:
No, it isn't. You can duplicate it though with a standard tableview and a couple custom background images.
You have to change both cell.backgroundView and cell.selectedBackgroundView with a view of your choice.

(iphone) aqgridview question. how to make shelf?

I'm using aqgridview to create a book-shelf like UI.
I can place image and title for image fine (with the ImageDemo example provided in aqgridview).
I want to place 'shelf' image where the image title is. (as in http://itunes.apple.com/ca/app/rivet-for-ipad/id375055319?mt=8)
I can set the background color of the label for title but the shelf background image won't be there where there's no cell in the first place.
Hence shelf image doesn't cover the entire screen width.
How can I stretch the shelf image?
Thank you
i'm also using AQGridView for a book grid with shelves, i found the best and fastest way to do this is simply use a UITableView.
Create a UITableView and add the shelves images as rows (Configure UITableViewCell)
Set the AQGridView backgroundView to the UITableView
_gridView.backgroundView = _tableView
you can use
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
to use different shelf graphics for different shelfes
but i'm guessing you already found way by now.

How can set the background view of a UITableViewCell to the selected background when it is not selected?

I created a custom implementation of a multi-selectable table view. Multiple rows can be selected programatically. The only part I haven't been able to figure out is how to programatically set the background view of cell to the default system cell selected color/pattern.
Does anyone know how to do this?
Thanks!
Could you please post your method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Same code can help to understand the problem :)
Are you asking how to programatically select rows?
If so, then use the ‘selectRowAtIndexPath:animated:scrollPosition:‘ method call, or create the cell with
cell.selected = YES;
For the first cell, set it to selected as normal. For other cells, get the class of the backgroundView of the first selected cell, instantiate a new object of that class, and assign it as the background view.
otherCell.backgroundView = [[[[[firstCell backgroundView] class] alloc] init] autorelease];