Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton not setting alpha properly
    primarykey
    data
    text
    <p>This is probably a stupid mistake of mine, but I have 3 UIbuttons, 2 of which are hidden by default, and 1 which is supposed to reveal the 2 others when clicked on. I call this method in my viewDidLoad:</p> <pre><code>-(void) initButtons { self.checkbutton = [[UIButton alloc] initWithFrame:CGRectMake(20, 330, 80, 70)]; self.checkbutton.backgroundColor = [UIColor clearColor]; [self.checkbutton setBackgroundImage:[UIImage imageNamed:@"checkbutton"] forState:UIControlStateNormal]; self.checkbutton.enabled = NO; self.checkbutton.alpha = 0.0; [self.view addSubview:self.checkbutton]; self.xbutton = [[UIButton alloc] initWithFrame:CGRectMake(230, 330, 70, 70)]; self.xbutton.backgroundColor = [UIColor clearColor]; [self.xbutton setBackgroundImage:[UIImage imageNamed:@"X.png"] forState:UIControlStateNormal]; self.xbutton.enabled = NO; self.xbutton.alpha = 0.0; [self.view addSubview:self.xbutton]; } </code></pre> <p>And when my visible button is clicked, this method is called:</p> <pre><code>-(void) showbuttons { self.checkbutton.enabled = YES; [[self checkbutton] setAlpha:1.0]; self.xbutton.enabled = YES; [[self xbutton] setAlpha:1.0]; NSLog(@"xbutton alpha: %f", [[self xbutton] alpha]); NSLog(@"checkbutton alpha: %f", [[self checkbutton] alpha]); } </code></pre> <p>What happens is that when I click the visible button, only 1 button appears. (xbutton) They should be coded in the exact same way, I don't know what's wrong. The NSLogs that I have show that both buttons have an alpha value of 1.0. I'm sure I @propertied and @synthesized checkbutton correctly, it's just like the xbutton.</p> <p>What am I doing wrong?</p> <p>Also, a side question: what's the difference between <code>[checkbutton setAlpha]</code> and <code>[self.checkbutton setAlpha]</code>?</p> <p>Ughh... My fault. My image was named checkmark.png and not checkbutton.png. Thanks to @DanielRHicks for answering my side question though.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload