【发布时间】:2018-08-30 15:12:38
【问题描述】:
执行以下操作的“最佳”(或更好)方法是什么?
在轮播页面(比如 6 个内容页面)中,我单击一个按钮,部分操作会更改该按钮上的文本,但它也必须针对所有其他内容页面进行更改。
我目前在轮播页面 OnCurrentPageChanged() 中发生了这种情况,我在其中调用一个函数并传入“this”。 helpers.ChangeAll(this);
public void ChangeAll(CarouselSwipePage page)
{
foreach (SwipePageContent v in page.Children)
{
Button b = v.Content.FindByName<Button>("pause");
if (GlobalSettings.Settings.Default.CarouselCountEnabled) //this is set elsewhere and is used to determine whether the carousel is changing automatically, if it is then set the text to pause
{
b.Text = FontAwesomeFont.PauseCircleO;
}
else
{
b.Text = FontAwesomeFont.PlayCircleO;
}
}
}
这在 android 上工作正常,但在 ios 上,当用户在单击按钮后滑动到下一个内容页面时,由于调用 OnCurrentPageChanged() 的函数,按钮文本在更改为新值之前暂时是旧值。
除此之外,我确信一定有更好的方法来做到这一点,它看起来很垃圾。
【问题讨论】:
标签: c# android ios xamarin.forms