tags:

views:

280

answers:

2

Hi all,
I'm working on a very simple application for iPhone now. On some state, the application shows a table and a layer over it. the layer contains a background image and a button.

When clicking the button - nothing happens. instead - the table selected row is being triggered.

What am I doing wrong?

David.

A: 

Did you remove the table view from the superview?

[viewWithTableInIt removeFromSuperview];
[theview addSubivew:viewWithBackgroundImageAndButton];

or if you need to keep the "layer" (I assume you mean a view) with the table in it as a subview, you could do

viewWithTableInIt.hidden = YES;
Mk12
+1  A: 

Layers are for drawing, not handling events. To respond to touch events, you generally need to be a subclass of UIResponder (which CALayer is not). So, how have you put this layer over the UITableView? If it really is a CALayer, then this isn't going to work; you need to use a UIView. If it's really a UIView that you just called a layer, then provide some information about how you created the view. The most likely cause for a view to not respond is for hitTest:withEvent: to fail as described in the UIView docs:

This method ignores views that are hidden, that have disabled user interaction, or have an alpha level less than 0.1.

Rob Napier