创建一个综合浏览器控制器时遇到了很多麻烦。我已经对我的代码进行了三次调整但是我保持得到以下错误:'Objective C方法的预期选择器'。我还收到另一条错误消息,上面写着'Missing'@end'。谁能告诉我为什么我收到这些消息? :升
#import "InstructionContentViewController.h"
#import "StorageViewController.h"
@interface StorageViewController ()
@end
@implementation StorageViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Create the data model
_pageTitles = @[@"Over 200 Tips and Tricks", @"Discover Hidden Features", @"Bookmark Favorite Tip", @"Free Regular Update"];
_pageImages = @[@"instructions1.png", @"instructions2.png", @"instructions3.png", @"instructions4.png"];
// Create page view controller
self.instructionViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"InstructionViewController"];
self.instructionViewController.dataSource = self;
InstructionContentViewController *startInstructViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startInstructViewController];
[self.instructionViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
// Change the size of page view controller
self.instructionViewController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 50);
[self addChildViewController:_instructionViewController];
[self.view addSubview:_instructionViewController.view];
[self.instructionViewController didMoveToParentViewController:self];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)startWalkthrough:(id)sender {
InstructionContentViewController *startingInstructViewController = [self viewControllerAtIndex:0];
NSArray *viewControllers = @[startingInstructViewController];
[self.instructionViewController setViewControllers:viewControllers direction:UIPageViewControllerNavigationDirectionReverse animated:NO completion:nil];
}
#pragma mark - Page View Controller Data Source Methods:
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController
{
NSUInteger index = ((InstructionContentViewController*) viewController).pageIndex;
if ((index == 0) || (index == NSNotFound)) {
return nil;
}
index--;
return [self viewControllerAtIndex:index];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController
{
NSUInteger index = ((InstructionContentViewController*) viewController).pageIndex;
if (index == NSNotFound) {
return nil;
}
index++;
if (index == [self.pageTitles count]) {
return nil;
}
return [self viewControllerAtIndex:index];
}
- (InstructionContentViewController *)viewControllerAtIndex:(NSUInteger)index
{
if (([self.pageTitles count] == 0) || (index >= [self.pageTitles count])) {
return nil;
}
// Create a new view controller and pass suitable data.
InstructionContentViewController *instructionContentViewController = [self.storyboard instantiateViewControllerWithIdentifier:@"InstructionContentViewController"];
instructionContentViewController.instructimageFile = self.pageImages[index];
instructionContentViewController.instructtitleText = self.pageTitles[index];
instructionContentViewController.pageIndex = index;
return instructionContentViewController;
}
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController
{
return [self.pageTitles count];
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController
{
return 0;
}
@end
答案 0 :(得分:0)
在#import
的其中一个文件(InstructionContentViewController.h或StorageViewController.h)中可能存在语法错误。
由于处理导入的方式,警告有时会出现在意外的地方。验证它们是否格式正确,以及可以从那些文件中导入的任何其他文件。
此外,在Xcode中,您可以单击“产品”菜单并按住Option键以获取“Clean Build Folder”命令。这将清除预编译的数据并强制从头开始重新编译所有内容。