使用 UIPageControl 在按钮按下时发送数据和更改页面 [英] Send data and Change Page on button press using UIPageControl

查看:29
本文介绍了使用 UIPageControl 在按钮按下时发送数据和更改页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 UIPageControlUIScrollView 通过滚动在视图之间移动.

I am using UIPageControl and UIScrollView to move between the views by scrolling.

我已关注此教程.

我在第一个视图控制器中有一个按钮.我想将数据发送到第二个视图控制器并更改页面.我想知道它是如何完成的.

I have a button in the first of the view controllers. I would like to send data to the second view controller and also change the page. I would like to know how it is done.

推荐答案

您需要创建所有视图控制器(至少生成前 2 个),而不是纯粹按需加载(滚动).

You would need to have all of the view controllers created (born at least the first 2) rather than loading purely on demand (scroll).

向第一个控制器添加一个属性,该属性保存对第二个控制器的引用.创建实例时设置引用.

Add a property to the first controller which holds a reference to the second controller. Set the reference when the instances are created.

点击按钮时,使用引用调用第二个控制器上的方法.

When the button is tapped, use the reference to call a method on the second controller.

这篇关于使用 UIPageControl 在按钮按下时发送数据和更改页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆