【发布时间】:2017-05-08 01:58:09
【问题描述】:
我正在开发一个使用 UIPageViewController 的应用程序,以便我可以从左向右滑动以浏览页面 (ViewControllers)。自从我的原始帖子以来,我已经编写了代码。但我收到三个错误。
错误 1:在“IntroPages”类型的对象上找不到属性“delegate” 错误 2:在“IntroPages”类型的对象上找不到属性“dataSource” 错误 3:“IntroPages”没有可见的@interface 声明选择器“setViewControllers:direction:animated:completion:”
所有三个错误都在 viewDidLoad 的第一部分(部分在 {} 大括号中)。前两个是 viewDidLoad 下面的代码,第三个是 5 行。
委托和数据源在 .h 文件中被引用。为什么他们没有被发现?为什么“IntroPages”没有可见的@interface?
代码如下。
IntroPages.h
#import <UIKit/UIKit.h>
@interface IntroPages : UIViewController
<UIPageViewControllerDelegate, UIPageViewControllerDataSource>
@end
IntroPages.m
#import "IntroPages.h"
@interface IntroPages ()
@end
@implementation IntroPages
{
NSArray *myViewControllers;
}
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.delegate = self;
self.dataSource = self;
UIViewController *p1 = [self.storyboard
instantiateViewControllerWithIdentifier:@"Intro1ID"];
UIViewController *p2 = [self.storyboard
instantiateViewControllerWithIdentifier:@"Intro2ID"];
UIViewController *p3 = [self.storyboard
instantiateViewControllerWithIdentifier:@"Intro3ID"];
UIViewController *p4 = [self.storyboard
instantiateViewControllerWithIdentifier:@"Intro4ID"];
myViewControllers = @[p1,p2,p3,p4];
[self setViewControllers:@[p1]
direction:UIPageViewControllerNavigationDirectionForward
animated:NO completion:nil];
NSLog(@"loaded!");
}
@end
【问题讨论】:
-
那么你面临的问题是什么......以及你尝试了什么......?发布你的代码。
-
我编辑了我所在位置的帖子。包含代码。
标签: ios objective-c uipageviewcontroller