ios - Using UISegmentedControl to show/hide buttons -


how can use uisegmentedcontrol in objective c programming show or hide buttons on screen?

another question on site showed code:

if (selectedsegment == 0) {     [firstview sethidden:no];     [secondview sethidden:yes]; } else {     [firstview sethidden:yes];     [secondview sethidden:no]; } 

but how put firstview , secondview? please add uibutton example if shows me example. note: cannot use view based application this, due fact program pretty far along. in advance.

after @implementation line in view controller:

uibutton *firstbutton; uibutton *secondbutton; 

in view controller, in viewdidload function (or wherever want initialize buttons), initialize buttons so:

firstbutton = [uibutton buttonwithtype:(uibuttontyperoundedrect)]; [firstbutton setframe:cgrectmake(20, 100, 50, 50)]; secondbutton = [uibutton buttonwithtype:(uibuttontyperoundedrect)]; [secondbutton setframe:cgrectmake(20, 150, 50, 50)]; 

obviously, change style choosing , use cgrectmake position buttons somewhere on screen. when want hide/show button:

if (selectedsegment == 0) {     [firstbutton sethidden:no];     [secondbutton sethidden:yes]; } else {     [firstbutton sethidden:yes];     [secondbutton sethidden:no]; } 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -