Note that there are some explanatory texts on larger screens.

plurals
  1. POUIButton setHidden not working now?
    primarykey
    data
    text
    <p>I have 10 or so buttons setup inside a method as follows:</p> <pre><code>@implementation MyViewController UIButton *originalButton; etc... - (void)setupButtons { originalButton = [UIButton buttonWithType:UIButtonTypeCustom]; [originalButton addTarget:self action:@selector(originalButtonWasPressed:) forControlEvents:UIControlEventTouchUpInside]; originalButton.frame = CGRectMake(20.0, 30.0, 100.0, 39.0); UIImage *buttonImage = [[UIImage imageNamed:@"originalreg.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)]; UIImage *buttonImageHighlight = [[UIImage imageNamed:@"originalregblue.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)]; [originalButton setBackgroundImage:buttonImage forState:UIControlStateNormal]; [originalButton setBackgroundImage:buttonImageHighlight forState:UIControlStateHighlighted]; [self.view addSubview:originalButton]; etc… } </code></pre> <p>I decided to pull the common code into another method for efficiencies:</p> <pre><code>- (void)setupButton:(UIButton *)myButton withSelector:(SEL)selector withX:(CGFloat)x withY:(CGFloat)y withRegImage:(NSString *)regImage withHighlightImage:(NSString *)highlightImage { myButton = [UIButton buttonWithType:UIButtonTypeCustom]; [myButton addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside]; myButton.frame = CGRectMake(x, y, 100.0, 39.0); UIImage *buttonImage = [[UIImage imageNamed:regImage] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)]; UIImage *buttonImageHighlight = [[UIImage imageNamed:highlightImage] resizableImageWithCapInsets:UIEdgeInsetsMake(18, 18, 18, 18)]; [myButton setBackgroundImage:buttonImage forState:UIControlStateNormal]; [myButton setBackgroundImage:buttonImageHighlight forState:UIControlStateHighlighted]; [self.view addSubview:myButton]; } </code></pre> <p>…and call it as such:</p> <pre><code>- (void)setupButtons { [self setupButton:originalButton withSelector:@selector(originalButtonWasPressed:) withX:20.0 withY:30.0 withRegImage:@"originalreg.png" withHighlightImage:@"originalregblue.png"]; etc... } </code></pre> <p><strong>THIS ALL WORKS</strong> except, one of my buttons is used to hide all the others. In the original setup, pressing the "Hide Buttons" button resulted in the other buttons being hidden. Now, they remain on the screen. Here's the code for that:</p> <pre><code>[self setupButton:hideButtonsButton withSelector:@selector(hideButtonsButtonWasPressed:) withX:20.0 withY:530.0 withRegImage:@"hidebuttonsreg.png" withHighlightImage:@"hidebuttonsregblue.png"]; - (void)hideButtonsButtonWasPressed:(id)sender { // hide the buttons originalButton.hidden = YES; originalButton.enabled = NO; etc… } </code></pre> <p>I've confirmed this method is being called and the <code>setHidden/setEnabled</code> calls are being executed. </p> <p>Any pointers gratefully received! Tony.</p>
    singulars
    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