无法从函数调用参数

时间:2013-02-17 18:28:51

标签: ios cocoa-touch

我的应用程序在调用函数时有构建字段 它显示了Mach-O Linker Error 我哪里弄错了?

-(void)viewDidAppear:(BOOL)animated
 {
    ScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, self.view.frame.size.width, self.view.frame.size.height-88)];
    ScrollView.pagingEnabled = YES;

    ScrollView.contentSize = CGSizeMake(self.view.frame.size.width*13, self.view.frame.size.height-88);
    [self.view addSubview:ScrollView];

    arrImages = [NSArray arrayWithObjects:@"image-001", @"image-002", nil];

    LoadImage:(1);
}

-(void)LoadImage:(int *)index;
{
    ImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-88)];

    [ImageView setImage:[arrImages objectAtIndex:index]];
    [ScrollView addSubview:ImageView];
}

2 个答案:

答案 0 :(得分:2)

该行:

LoadImage:(1);

应该是:

[self LoadImage:1];

此外,您的LoadImage:方法应采用int类型的参数,而不是int *

这些是一些非常基本的错误。我建议你花一些时间来学习Objective-C的基础知识。

答案 1 :(得分:0)

LoadImage:(1);  // <--- error

[self LoadImage:1]; // <--- like that

编辑: 正如@Till指出的那样,也要将你的声明改为int:

在标题(.h)中:

-(void)LoadImage:(int)index;

在实施(.m)中:

-(void)LoadImage:(int)index { //<--- lose that semi-colon
...
}

所有这些修复工作都应该做到这一点