Best way to handle enable/disable of UIButtons on iPhone
Posted
by Anonymous
on Stack Overflow
See other posts from Stack Overflow
or by Anonymous
Published on 2010-04-10T23:40:46Z
Indexed on
2010/04/10
23:43 UTC
Read the original article
Hit count: 213
I have an increase button and a decrease button, both of which affect a variable. The variable has a minimum and the decrease button will be disabled once that minimum is reached. Likewise for the maximum value of the variable. In my controller, I have two IBActions for both the increase and decrease actions, and two IBOutlets, in order to disable the buttons accordingly. At the bottom of my KVO statement to handle the value change, I have:
increaseButton.enabled = value != MAX; decreaseButton.enabled = value != MIN;
While this code is functional, I can't help but feel that feel this is a naive approach to the problem, especially since this requires 4 connections. Is there a better solution to this, one that uses fewer connections?
© Stack Overflow or respective owner