ios - Using tags in Swift -


i have 15 uibuttons in controller. im trying clear 10 of them simple loop , looks getting kind of conflict.

when hit button clear, following error:

could not cast value of type '_uisizetrackingview' (0x18a023c) 'uibutton' (0x1899298). (lldb)

for loop :

for var = 0; < 9; i++ {     button = view.viewwithtag(i) as! uibutton     button.setimage(nil, forstate: .normal) } 

i have narrowed down issue item using tag 0. have looked @ items on view controller scene , can not seem find conflicts. see 1 button using tag = 0.

i confrimed replacing 'i' in loop '0' , got same issue. when replaced '1' or '2', works fine single image.

any way see object using tag 0? have clicked on them ( including main 'view') cant seem find anything.

as there said @ranunez, default tag 0. don't agree advice use non-zero tags.

my advice is, don't use tags @ all. if want use view in code, declare outlet , connect it. if want iterate on several views, create array outlets or use collection of outlets:

@iboutlet var buttons: [uibutton]! 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -