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

use*_*386 3 xcode objective-c

我有一个视图控制器.当我传递一个额外的对象我得到这个错误@No可见界面在下面的函数.你可以帮助我.下面是code.where我传递类型照片的对象..

  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;
Run Code Online (Sandbox Code Playgroud)

}

Rol*_*som 6

将其更改为:

- (id)initWithFrame:(CGRect)frame andPhoto:(Photo *)photo
Run Code Online (Sandbox Code Playgroud)

还要记得将它添加到.h文件中.