My problem's pretty simple. I have a UITableViewController (well, I subclassed it, but that's not the issue), with a static layout, and it's large enough it doesn't fit on the screen all at one time.
I'm using viewWithTag
to retrieve the values of a couple UISwitch
es, but they're just off the screen, so viewWithTag
is infuriatingly returning nil.
Frankly, I neither know nor care about the memory overhead of leaving them in memory; it's not much memory to leave lying around, and I'm short on time.
How can I prevent scrolling from triggering deallocation?
EDIT: I know exactly what's wrong, as explained above, just not how to fix it (my usual google-fu came up dry). But since you asked to see the code...
int tag=200
int prefs = 0;
for (int i=0; i != 3; ++i) // There are only 3 preferences
{
prefs = prefs << 1;
UISwitch *swt = (UISwitch *)[self.view viewWithTag:tag + i];
NSLog(@"%@", swt);
if ([swt isOn])
++prefs;
NSLog(@"%d", prefs);
}
The above code works in viewDidAppear (because the switches are at the top of the table), but not once I have scrolled to the bottom of the table (viewWithTag returns null).