views:

87

answers:

1

Hello I have a matrix of buttons, 4x3 And i have the following problems, or let's say i don't know where to begin

  1. they are inited with a label from an array and they call the same function -(IBAction)buttonPressed:(id)sender Buttons are made programatically, not sure the function needs IBAction. How do i detect in this function what button was pressed? i thought at something like sender.label but is not working. Here's how i call it:

    [playButton addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventTouchUpInside];

  2. How do i detect the touch? i want to display an uiView somewhere when i touch a button, not when i release it.

  3. What to use to create a mask with rounded corners over this buttons? The buttons stay on a rounded rectangle but the buttons itself are squared, so they look ugly in the corners of the matrix.

+3  A: 
  1. You can assign each button unique tag, e.g.

    myNewButton.tag = myNewTag; ++myNewTag;

then in your IBAction method you can get sender's tag (via (UIButton*)sender.tag) and proceed accordingly.

  1. there's UIControlEventTouchDown event. (you can see the complete event list in UIControl class reference in Control events section)

  2. I usually just use images with rounded corners for buttons when needed (and set button type to custom)

Vladimir
thanks, i'll try them. i thought myself at the last solution but i was afraid of using to many pngs, but i think i'll go this way, i need only for the touched state because the normal state is transparent. Maybe i can rotate and flip the image to fit each corner.
Cristi Băluță