I am working on a Swift application that needs to set the application scope from a tableView -- the user will select a list item which will then set an ID which controls the data loaded in other views. I am currently opening the tableView as a modal but I am not sure what is the best practice for closing the modal from within the setSelected(selected: Bool, animated: Bool)
function call of a custom tableViewCell subclass (or even if dismissing the modal from this function is the best practice). I was considering passing a reference of the parent view that loaded the modal and then using dismissViewControllerAnimate
but that is not working.
Edit : my original post seemed to be unclear so I will try to clearly ask my questions:
1.) I need dismiss the modal view and the only function I have come across so far is dismissViewControllerAnimate
-- is this the function I should be using or are there others for others uses?
2.) If dismissViewControllerAnimate
is the correct function, should I be calling it from within the setSelected
function of the tableViewCell?
3.) If I should call from within setSelected
, should I pass a reference of the ViewController to the tableViewCell so that it can call dismissViewControllerAnimate
from setSelected
?
/Edit
Any help or suggestions will be much appreciated!
我的建议是处理表格视图控制器中的didSelectRowAtIndexPath方法,并在注意到选择了哪个单元格后从那里调用dismissViewControllerAnimated。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.