如何解决uiscrollview错误

发布于 2024-11-06 01:50:57 字数 2405 浏览 1 评论 0原文

谁能告诉我为什么我会收到此错误?

[我的班级名称 表视图:numberOfRowsInSection:]: 无法识别的选择器发送到实例 0x8ad5a90'

我知道这是什么意思,但在 myClassName 类中我没有使用任何 uitableview!!!!我在这个类中有一个滚动视图,而不是 tableView,所以我找不到为什么会收到此错误。

编辑:

- (void)viewDidLoad 
{
imageIndex = 0;
int count =0;
int totalScrollRow = 0;

myScroll.contentSize = CGSizeMake(0, 397);
NSLog(@"%f",myScroll.contentSize.height);

volPhotoApp = (MyAppDelegate *) [[UIApplication sharedApplication] delegate];

volPhotoApp.photoGalleryIndex = 0 ;

eventRow = [volPhotoApp.volPhotoArray objectAtIndex:selectedIndex];
numberOfImages = [eventRow.photoArray count];

if (numberOfImages == 0)
{
    UILabel *zeroLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
    zeroLabel.text = @"No Images..";

    [myScroll addSubview:zeroLabel];
    return;
}

header.enabled =NO;
[header setTitle:eventRow.title forState:UIControlStateNormal];

CGRect contentRect = myScroll.bounds;

CGFloat boundX = contentRect.origin.x;

CGFloat boundY = contentRect.origin.y;

CGRect frame1 ;

for (int i=0, X=5 ; i < numberOfImages; i++, X+=80)
{       
    if (count == 4)
    {
        boundX = 5;

        boundY += 70;

        X = 0;

        count = 0;

    }

    frame1 = CGRectMake(boundX+X ,boundY+5, 70, 65);
    AsyncImageView *av1 = [[AsyncImageView alloc] initWithFrame:frame1];
    [av1 loadImageFromURL:[NSURL URLWithString:[eventRow.photoArray objectAtIndex:volPhotoApp.photoGalleryIndex]]];
    av1.backgroundColor = [UIColor clearColor];
    volPhotoApp.photoGalleryIndex++;

    UIButton *b1 = [[UIButton alloc] initWithFrame:frame1];
    b1.backgroundColor = [UIColor clearColor];
    [b1 setTitle:@"" forState:UIControlStateNormal];
    b1.tag = volPhotoApp.photoGalleryIndex;
    [b1 addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
    b1.enabled = YES;
    count++;

    [myScroll addSubview:av1];

    [myScroll addSubview:b1];
    totalScrollRow++;

    if (volPhotoApp.photoGalleryIndex == numberOfImages)
    {
        volPhotoApp.photoGalleryIndex = 0 ;
        break;
    }

}   
NSLog(@"%f",boundY);
NSLog(@"%d",totalScrollRow);

NSLog(@"%f",myScroll.contentSize.height);

if (boundY > myScroll.contentSize.height || totalScrollRow > 20)
{
    myScroll.contentSize = CGSizeMake(0, boundY+75);
}

[super viewDidLoad];
  }

谢谢..

Can any one tell me why I am getting this error ?

[myClassName
tableView:numberOfRowsInSection:]:
unrecognized selector sent to instance
0x8ad5a90'

I know what does it means but in myClassName class I didn't use any uitableview!!!! I have a scrollview in this class not tableView so I could not find why I am getting this error.

EDITED :

- (void)viewDidLoad 
{
imageIndex = 0;
int count =0;
int totalScrollRow = 0;

myScroll.contentSize = CGSizeMake(0, 397);
NSLog(@"%f",myScroll.contentSize.height);

volPhotoApp = (MyAppDelegate *) [[UIApplication sharedApplication] delegate];

volPhotoApp.photoGalleryIndex = 0 ;

eventRow = [volPhotoApp.volPhotoArray objectAtIndex:selectedIndex];
numberOfImages = [eventRow.photoArray count];

if (numberOfImages == 0)
{
    UILabel *zeroLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 200)];
    zeroLabel.text = @"No Images..";

    [myScroll addSubview:zeroLabel];
    return;
}

header.enabled =NO;
[header setTitle:eventRow.title forState:UIControlStateNormal];

CGRect contentRect = myScroll.bounds;

CGFloat boundX = contentRect.origin.x;

CGFloat boundY = contentRect.origin.y;

CGRect frame1 ;

for (int i=0, X=5 ; i < numberOfImages; i++, X+=80)
{       
    if (count == 4)
    {
        boundX = 5;

        boundY += 70;

        X = 0;

        count = 0;

    }

    frame1 = CGRectMake(boundX+X ,boundY+5, 70, 65);
    AsyncImageView *av1 = [[AsyncImageView alloc] initWithFrame:frame1];
    [av1 loadImageFromURL:[NSURL URLWithString:[eventRow.photoArray objectAtIndex:volPhotoApp.photoGalleryIndex]]];
    av1.backgroundColor = [UIColor clearColor];
    volPhotoApp.photoGalleryIndex++;

    UIButton *b1 = [[UIButton alloc] initWithFrame:frame1];
    b1.backgroundColor = [UIColor clearColor];
    [b1 setTitle:@"" forState:UIControlStateNormal];
    b1.tag = volPhotoApp.photoGalleryIndex;
    [b1 addTarget:self action:@selector(aMethod:) forControlEvents:UIControlEventTouchDown];
    b1.enabled = YES;
    count++;

    [myScroll addSubview:av1];

    [myScroll addSubview:b1];
    totalScrollRow++;

    if (volPhotoApp.photoGalleryIndex == numberOfImages)
    {
        volPhotoApp.photoGalleryIndex = 0 ;
        break;
    }

}   
NSLog(@"%f",boundY);
NSLog(@"%d",totalScrollRow);

NSLog(@"%f",myScroll.contentSize.height);

if (boundY > myScroll.contentSize.height || totalScrollRow > 20)
{
    myScroll.contentSize = CGSizeMake(0, boundY+75);
}

[super viewDidLoad];
  }

Thanks..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

豆芽 2024-11-13 01:50:57

您可以继承 UITableViewController 或充当委托吗?没有代码,它只是猜测。

Could you be inheriting from UITableViewController or acting as the delegate? Without code it's only guessing.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文