如何解决uiscrollview错误
谁能告诉我为什么我会收到此错误?
[我的班级名称 表视图: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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以继承 UITableViewController 或充当委托吗?没有代码,它只是猜测。
Could you be inheriting from UITableViewController or acting as the delegate? Without code it's only guessing.