iosTable remember selected row

I have a view with a table, when a user taps a row a new view is displayed. When the user hits the back button and the original view with the table is shown, I would like the row that was selected to still be selected?

Or a way to look up the value that I saved.

You could save the selected section and row in the Action event handler for the table before you show the new view. When the original View is again displayed you can then use the Activate event to get the saved row to select the row in the table again. In order to select a row in a table, you need to use a Declare, which is in this example included with Xojo:


Paul thanks again!

I haven’t dealt with declares like this since my Old Visual Basic days, some 20 years ago!

Xojo iOS is still a baby. As it fills out with more of the standard features it will become exceptionally more useful. Even with all of the declares it’s still many, many times faster than developing in Xcode & ObjectiveC in my experience.


Finally at the point to implement this.

In looking at the example I have a question.

Can I put these declares in the App open and will they be available through out the app? Or do I have to put them all in the Method they will be used?

And where should I put the call to select the row that was selected before the new view was pushed? I would assume in the Activate Event of the View.

These Declares go within a method, but it doesn’t matter where the method is. The same rules apply here as would for any method that you want to access globally: you’ll need to make sure any info that the method needs is passed to it.

Yes, that seems like a good place to me.

Found an issue.

If the Table has Sections, it only works for the first section.

Any way around that?

There ought to be. Let me take a look.

OK, it already does support section and row, not that it is easy to determine that.

This line sets the section:

initPath(rowPath, 0)

This line sets the row:

fullPath = addIndex(rowPath, 30)

I’m going to update the example to put this in a method that a bit easier to use for r3.

Works great!