Also, it would be useful if you post an entire example (including your view setup and present) so we're are not debugging something more basic.
When posting code in the forum, first tap the </> symbol that appears at the top of the text entry area. Then paste code you copied from the pythonista editor between the triple backticls. That way autocorrect doesn't try to change caps or indents..