gpt4 book ai didi

ios - 将 UITableView 添加到 UIPageViewController 时,“无法识别的选择器发送到实例”

转载 作者:行者123 更新时间:2023-12-01 18:05:47 24 4
gpt4 key购买 nike

我正在尝试创建一个 PageViewController,其中包含多个水平分页 UITableViews。 UITableViews 存储在一个数组中;我使用 UIPageViewController setViewControllers将数组中的第一个对象添加到 PageVC 的方法:

 [self.pageViewController setViewControllers:[self.tableViews objectAtIndex:0] direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];

然后我使用 viewControllerBeforeViewController 将剩余的 UITableViews 添加到 PageViewController和 viewControllerAfterViewController方法。

然而 setViewControllers方法产生以下错误:
 -[UITableView count]: unrecognized selector sent to instance 0x7c347e00
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UITableView count]: unrecognized selector sent to instance 0x7c347e00'

为什么会发生此错误?

最佳答案

你应该先看看你使用的方法here :

- (void)setViewControllers:(NSArray<UIViewController *> *)viewControllers 
direction:(UIPageViewControllerNavigationDirection)direction
animated:(BOOL)animated
completion:(void (^)(BOOL finished))completion;

它说参数应该是viewControllers

Parameters:

viewControllers The view controller or view controllers to be displayed.



所以,你必须采取 UIViewcontrollerUITableViewController .

关于ios - 将 UITableView 添加到 UIPageViewController 时,“无法识别的选择器发送到实例”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45095132/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com