【问题标题】:how to solve uiscrollview error如何解决uiscrollview错误
【发布时间】:2011-05-06 06:07:15
【问题描述】:

谁能告诉我为什么会出现这个错误?

[我的班级名称 表视图: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];
  }

谢谢..

【问题讨论】:

  • @Maulik:请您的代码..
  • myClassName 是您程序中某些 UITableView 的数据源委托。也许您忘记在 Interface Builder 中删除绑定?
  • 我在第一次尝试时所做的我使用了 UITableView 然后我删除了那个 xib 文件并创建了新的文件并使用了滚动视图..我还从硬盘中删除了那个旧的 xib..
  • 你这个错误是随机发生的......有时它工作正常,有时它没有!!!
  • 注意:你应该先调用[super viewDidLoad],然后添加你自己的代码。

标签: iphone uitableview ios4 uiscrollview


【解决方案1】:

你可以继承 UITableViewController 还是充当代理?没有代码,它只是猜测。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-29
    • 2018-06-30
    • 2012-02-18
    • 2011-08-30
    • 2014-06-13
    • 2011-07-06
    • 2018-09-17
    • 2019-08-14
    相关资源
    最近更新 更多