I just created a New Xcode Project as a Page-Based Application and I want to add a new button that will create a new page on runtime. How can I do that?
我刚刚创建了一个新的Xcode项目作为基于页面的应用程序,我想添加一个新的按钮,它将在运行时创建一个新的页面。我怎样才能做到这一点?
Actually, an app called "Dwindle" has it. It's free to download, just saying it for if someone wants to know what I am talking about.
实际上,一款名为“Dwindle”的应用程序拥有它。它可以免费下载,只是说如果有人想知道我在说什么。
Thanks for help.
感谢帮助。
1 个解决方案
#1
0
This can be achieved. The UIPageViewController calculates the number of pages it has, from the delegate method - presentationCountForPageViewController:
. You can add a property in your class for example:
这可以实现。 UIPageViewController从委托方法 - presentationCountForPageViewController:计算它拥有的页数。您可以在类中添加属性,例如:
@property int total;
And you can return the property value from the delegate method this way.
并且您可以通过这种方式从委托方法返回属性值。
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
// The number of items reflected in the page indicator.
return self.total;
}
And whenever an event occurs (Ex button click that you mentioned) - you can increment the value for the property - total
and re-render the pageViewController using the method - setViewControllers:
.
每当事件发生时(Ex按钮单击你提到的) - 你可以增加属性的值 - total并使用方法重新渲染pageViewController - setViewControllers :.
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
This will reload the pageViewController with the new value of total
.
这将使用新值total重新加载pageViewController。
#1
0
This can be achieved. The UIPageViewController calculates the number of pages it has, from the delegate method - presentationCountForPageViewController:
. You can add a property in your class for example:
这可以实现。 UIPageViewController从委托方法 - presentationCountForPageViewController:计算它拥有的页数。您可以在类中添加属性,例如:
@property int total;
And you can return the property value from the delegate method this way.
并且您可以通过这种方式从委托方法返回属性值。
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController {
// The number of items reflected in the page indicator.
return self.total;
}
And whenever an event occurs (Ex button click that you mentioned) - you can increment the value for the property - total
and re-render the pageViewController using the method - setViewControllers:
.
每当事件发生时(Ex按钮单击你提到的) - 你可以增加属性的值 - total并使用方法重新渲染pageViewController - setViewControllers :.
[self.pageController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
This will reload the pageViewController with the new value of total
.
这将使用新值total重新加载pageViewController。