gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 20:00:33 26 4
gpt4 key购买 nike

我有一个 View Controller 。当我传递一个额外的对象时,我收到此错误@No visible interface in the below function。你能帮我解决一下吗?下面是代码。我在哪里传递照片类型的对象..

  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 文件中。

关于objective-c - 是否可以在 UIView 类中传递参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13932488/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com