我正在尝试创建一个 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.
所以,你必须采取
UIViewcontroller
或 UITableViewController
.
关于ios - 将 UITableView 添加到 UIPageViewController 时,“无法识别的选择器发送到实例”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45095132/