Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Objective c 是否可以在UIView类中传递参数_Objective C_Xcode - Fatal编程技术网

Objective c 是否可以在UIView类中传递参数

Objective c 是否可以在UIView类中传递参数,objective-c,xcode,Objective C,Xcode,我有一个视图控制器。当我传递一个额外的对象时,我在下面的函数中得到了一个错误@No visible interface。你能帮我一下吗。下面是代码。我传递的对象类型是photo ItemImageView *itemImage = [[ItemImageView alloc]initWithFrame:CGRectMake(currentPhotoPositionX,0,pageButtonWidth,pageButtonHeight) andPhoto:photo]; @ItemImag

我有一个视图控制器。当我传递一个额外的对象时,我在下面的函数中得到了一个错误@No visible interface。你能帮我一下吗。下面是代码。我传递的对象类型是photo

  ItemImageView *itemImage = [[ItemImageView alloc]initWithFrame:CGRectMake(currentPhotoPositionX,0,pageButtonWidth,pageButtonHeight) andPhoto:photo];

@ItemImageview


 - (id)initWithFrame:(CGRect)frame :andPhoto:(Photo *)photo
   {
self = [super initWithFrame:frame];
if (self) {
    // Initialization code

    //Create Activity Indicator
     activityIndicator= [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(225, 115, 30, 30)];
    [activityIndicator setBackgroundColor:[UIColor clearColor]];
    [activityIndicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleWhite];
    [self addSubview:activityIndicator];

    //Create Label Comments

    lblComments = [[UILabel alloc] initWithFrame:CGRectMake(30.0f, 100.0f, 60.0f, 43.0f)];
    [lblComments setText:@"Comments"];
    [lblComments setBackgroundColor:[UIColor clearColor]];
    [self addSubview:lblComments];

    //Create Label Likes

    lblLikes = [[UILabel alloc] initWithFrame:CGRectMake(100.0f, 100.0f, 60.0f, 43.0f)];
    [lblLikes setText:@"Likes"];
    [lblLikes setBackgroundColor:[UIColor clearColor]];
    [self addSubview:lblLikes];


    //Create Item Button

    btnItem = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [btnItem addTarget:self
                action:@selector(:)
      forControlEvents:UIControlEventTouchUpInside];
    [btnItem setBackgroundImage:[UIImage imageNamed:@"1.png"] forState:UIControlStateNormal];
    btnItem.frame = CGRectMake(0.0f, 0.0f, 144.0f, 143.0f);
    [self addSubview:btnItem];


}

return self;
}

将其更改为:

- (id)initWithFrame:(CGRect)frame andPhoto:(Photo *)photo

还记得将其添加到您的.h文件中。

我无法这样做。我将函数定义更改为您给定的函数定义,当我调用函数时,会显示错误…我将更新我的答案:“:和照片:'删除第一个':”