开发者

Access switch and textfield in tableview from another method

开发者 https://www.devze.com 2023-01-18 05:00 出处:网络
I\'m having a tableview with a couple of cells with 4 uiswitches and开发者_开发问答 one textfield inside. Simple question. I need a way to read all the positions of the switches and the string inside

I'm having a tableview with a couple of cells with 4 uiswitches and开发者_开发问答 one textfield inside. Simple question. I need a way to read all the positions of the switches and the string inside the textview by clicking a button. Tableview, textfield, switches and button is working fine. Just need to access the values of the switches and textfield from another method. By tagging the switches or something.

So how can I access the values from another method. Something like in tableview method:

...

    UISwitch *switchView = [[option1 alloc] initWithFrame:CGRectZero];
    switchView.tag = 3000;

    cell.accessoryView = switchView;

...

And something like this in the button method:

...

BOOL status = [self.view viewWithTag:3000].on; //*Not a working method*


You are in the same class, nop ?

So maybe you could put your switch & co as class variable (declared in the header file). It would be easier ^^

0

精彩评论

暂无评论...
验证码 换一张
取 消