作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientat ion duration:(NSTimeInterval)duration {
UIInterfaceOrientation o = self.interfaceOrientation;
if ((o == UIInterfaceOrientationPortrait) || (o == UIInterfaceOrientationPortraitUpsideDown)) {D = 1;[self setPaging];}
if ((o == UIInterfaceOrientationLandscapeLeft) || (o == UIInterfaceOrientationLandscapeRight)) {D = 2;[self setPaging];}}
//-----------------------------------------------------------------------------*
-(ImageScrollView*)imagescrollview{
if(imagescrollview == nil){
imagescrollview = [[viewClass alloc] initWithFrame:CGRectZero];}
return imagescrollview;}
//--*duplicate
-(ImageScrollView2*)imagescrollview2{
if(imagescrollview2 == nil){
imagescrollview2 = [[viewClass alloc] initWithFrame:CGRectZero];}
return imagescrollview2;}
//-----------------------------------------------------------------------------*
- (ImageScrollView *)dequeueRecycledPage{
ImageScrollView *page = [recycledPages anyObject];
if (page) {
[[page retain] autorelease];
[recycledPages removeObject:page];}
return page;}
//--*duplicate
- (ImageScrollView2 *)dequeueRecycledPage2{
ImageScrollView2 *page = [recycledPages anyObject];
if (page) {
[[page retain] autorelease];
[recycledPages removeObject:page];}
return page;}
//-----------------------------------------------------------------------------*
- (void)tilePages {
if (D == 1) {
// Calculate which pages are visible
CGRect visibleBounds = pagingScrollView.bounds;
int firstNeededPageIndex = floorf(CGRectGetMinX(visibleBounds) / CGRectGetWidth(visibleBounds));
int lastNeededPageIndex = floorf((CGRectGetMaxX(visibleBounds)-1) / CGRectGetWidth(visibleBounds));
firstNeededPageIndex = MAX(firstNeededPageIndex, 0);
lastNeededPageIndex = MIN(lastNeededPageIndex, [self pdfPageCount] - 1);
// Recycle no-longer-visible pages
for (ImageScrollView *page in visiblePages) {
if (page.index < firstNeededPageIndex || page.index > lastNeededPageIndex) {
[recycledPages addObject:page];
[page removeFromSuperview];}}
[visiblePages minusSet:recycledPages];
// add missing pages
for (int index = firstNeededPageIndex; index <= lastNeededPageIndex; index++) {
if (![self isDisplayingPageForIndex:index]) {
ImageScrollView *page = [self dequeueRecycledPage];
if (page == nil) {
page = [[[ImageScrollView alloc] init] autorelease];}
[self configurePage:page forIndex:index];
[pagingScrollView addSubview:page];
[visiblePages addObject:page];}}}
else if (D == 2) {
// Calculate which pages are visible
CGRect visibleBounds = pagingScrollView.bounds;
int firstNeededPageIndex = floorf(CGRectGetMinX(visibleBounds) / CGRectGetWidth(visibleBounds));
int lastNeededPageIndex = floorf((CGRectGetMaxX(visibleBounds)-1) / CGRectGetWidth(visibleBounds));
firstNeededPageIndex = MAX(firstNeededPageIndex, 0);
lastNeededPageIndex = MIN(lastNeededPageIndex, [self pdfPageCount] - 1);
// Recycle no-longer-visible pages
for (ImageScrollView2 *page in visiblePages) {
if (page.index2 < firstNeededPageIndex || page.index2 > lastNeededPageIndex) {
[recycledPages addObject:page];
[page removeFromSuperview];}}
[visiblePages minusSet:recycledPages];
// add missing pages
for (int index = firstNeededPageIndex; index <= lastNeededPageIndex; index++) {
if (![self isDisplayingPageForIndex:index]) {
ImageScrollView2 *page = [self dequeueRecycledPage2];
if (page == nil) {
page = [[[ImageScrollView2 alloc] init] autorelease];}
[self configurePage2:page forIndex2:index];
[pagingScrollView addSubview:page];
[visiblePages addObject:page];}}}}
//-----------------------------------------------------------------------------*
- (void)configurePage:(ImageScrollView *)page forIndex:(NSUInteger)index{
page.index = index;
page.frame = [self frameForPageAtIndex:index];
[page displayTiledImageNamed:[self pdfPage: index] size:[self pdfSize: index]];}
//--*duplicate
- (void)configurePage2:(ImageScrollView2 *)page forIndex2:(NSUInteger) index {NSLog(@"1");
page.index2 = index;NSLog(@"4");
page.frame = [self frameForPageAtIndex:index];NSLog(@"5");
[page displayTiledImageNamed2:[self pdfPage: index] size:[self pdfSize: index]];NSLog(@"6");}
//-----------------------------------------------------------------------------*
@interface ImageScrollView : UIScrollView <UIScrollViewDelegate> {
UIView *imageView;
NSUInteger index;
}
@property (assign) NSUInteger index;
- (void)displayTiledImageNamed:(CGPDFPageRef)page size:(CGSize)imageSize;
@end
//--*duplicate
@interface ImageScrollView2 : UIScrollView <UIScrollViewDelegate> {
UIView *imageView;
NSUInteger index2;
}
@property (assign) NSUInteger index2;
- (void)displayTiledImageNamed2:(CGPDFPageRef)page size:(CGSize)imageSize;
@end
2010-08-22 03:02:36.532 PDFmag[31408:207] p4
2010-08-22 03:02:36.541 PDFmag[31408:207] *** -[ImageScrollView index2]: unrecognized selector sent to instance 0x148d10
2010-08-22 03:02:36.551 PDFmag[31408:207] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[ImageScrollView index2]: unrecognized selector sent to instance 0x148d10'
2010-08-22 03:02:36.565 PDFmag[31408:207] Stack: (
864992541,
859229716,
864996349,
864492313,
864454720,
21249,
18449,
21417,
838908048,
839266120,
839260480,
864766485,
839108308,
839107980,
839226672,
839225216,
839206800,
839205012,
875886564,
864740651,
864738335,
875880904,
838872112,
838865456,
11645,
11560
)
terminate called after throwing an instance of 'NSException'
Program received signal: “SIGABRT”.
最佳答案
首先...是吗?为什么要创建两个子类,一个子类带有index
,另一个子类带有index2
?乍看之下,这非常混乱,考虑到标准的OO设计模式,这似乎是完全不必要的。
它也似乎是问题的根本原因。即,您要传递ImageScrollView
的实例,这意味着您要传递ImageScrollView
的实例。
我要做的第一件事是摆脱方法名称上所有的2
废话。 ImageScrollView2
没有理由具有index2
。哎呀,你甚至可以:
@interface AbstractImageScrollView : UIScrollView <UIScrollViewDelegate> {
UIView *imageView;
NSUInteger index;
}
@property (assign) NSUInteger index;
- (void)displayTiledImageNamed:(CGPDFPageRef)page size:(CGSize)imageSize;
@end
@interface ImageScrollView1 : AbstractImageScrollView
...
@end
@interface ImageScrollView2 : AbstractImageScrollView
...
@end
-displayTileImageNamed:size:
。
关于objective-c - -[ImageScrollView index2]:无法识别的选择器已发送到实例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3543404/
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientat ion d
我正在 UITableViewCell (Swift 4) 中使用 ImageScrollView cocoa pod v1.5。我正在使用 SDWebImage 从 Firestore 下载图像(但
我是一名优秀的程序员,十分优秀!