Another iOS native control instantiation question

Graham Samuel livfoss at mac.com
Tue Apr 10 12:51:55 EDT 2012


Just to add to my message below, I have an interesting (at least to me!) real-life example. In my iOS app, I have a card with a scrolling list on it (an instantiated native control) and an action when a user touches one of the lines in the scrolled list which includes cloning some template cards in the stack and then returning to the original card. At this point in the app, the user only sees the original card because the cloning is hidden by a 'lock screen'.

I found that this meant that the preOpenCard message for the card was being invoked every time I did a set of clones and then returned to the original card - this is correct behaviour from the engine's point of view. I was able to use a switch (a custom property) checked in the preOpenCard handler to prevent the destruction and recreation of the scroller on this card during the cloning sequence. It works, which seems to show that you don't **have to** destroy native controls when you leave a card, and they will be waiting for you when you come back. This makes me even more confused about the necessity to destroy native controls.

Graham

I wrote:

> Can someone confirm that if one moves from card to card in an iOS app, any native controls (such as text input) need to be instantiated as the card is opened, and destroyed when another card is shown? This is very unlike the behaviour of LC on other platforms, where a field remains a field whether it's shown or not, that I feel I may have missed a trick here.
> 
> Suppose for example one of my cards is dedicated to input of several small and essentially unrelated data items, with a lot of little one-line fields which the user has to fill in. When the user decides to invoke this feature of the app, the 'input' card appears. At this point, if it's as described (a lot of little essentially identical fields), then presumably I just have to create one single-line input control which will appear each time one of my fields get the focus, and script the handling of each input text accordingly: and when the user steers away from this card I should destroy the control.
> 
> Is this right, and what would happen if I didn't do the destroy? I ask here because I'm getting overwhelmed by the need to experiment for almost every aspect of the behaviour of my iOS device and I'm frankly keen to learn from others' experience.




More information about the use-livecode mailing list