简体   繁体   English

一旦另一个类通过CA Transition设置了Xamarin iOS中的视图控制器上的隐藏属性

[英]How to set a hidden property on a view controller in Xamarin iOS once it has been set by another class with a CA Transition

这是布局的样子

I have a UI ViewController that has a UITableView controller embedded in it by means of a Container View and an Embed segue. 我有一个UI ViewController ,其中有一个通过Container ViewEmbed segue EmbedUITableView控制器。

So when the user clicks on the menu, a sliding menu pops out by means of a CATransition . 因此,当用户单击菜单时,将通过CATransition弹出滑动菜单。 On this menu, one of the options is "Home" that moves the menu back to it's original position and sets the Hidden property of this TableView Controller to true . 在此菜单上,选项之一是“主页”,它将菜单移回其原始位置并将此TableView Controller的Hidden属性设置为true

The next time you click on the Menu button, the menu does not pop out because the TableView Controller 's Hidden property was set to True in it's class when we clicked on the Home button. 下次单击菜单按钮时,菜单不会弹出,因为当我们单击“ Home按钮时, TableView ControllerHidden属性在其类中被设置为True

Summary Thus the problem is that once the user clicks on the Menu button, the current class needs to be able to set the hidden property of a TableView controller that is defined in another class. 结束语因此,问题在于,一旦用户单击“ Menu按钮,当前类就需要能够设置在另一个类中定义的TableView控制器的hidden属性。

I guess this is more to do with interaction between classes than mobile development, but I included the whole scenario as background. 我想这更多是与类之间的交互有关,而不是与移动开发有关,但是我将整个场景作为背景。

What is the best practice way of achieving this? 实现此目标的最佳做法是什么?

Create an additional constructor in the main class that excepts a parameter of type UITableView . 在主类中创建一个除了UITableView类型的parameter之外的其他构造函数。 Then pass the UITableView of class B as a parameter to the new constructor of the main class . 然后将B classUITableView作为parameter传递给主class的新constructor Then you can work with it from there. 然后,您可以从那里开始使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM