0

同様の質問がたくさんあることは知っていますが、どの回答も私の問題を解決するのに役立ちませんでした。

1つのウィンドウを移動すると機能があります:

-(void)flowLayout:(SEssentialsFlowLayout *)flow didDragView:(UIView *)view{
    NSLog(@"drag");
    BOOL needDeleteFavourites = NO;

    CGPoint dragScrollPosition =  [flow convertPoint:view.center toView:self];
    CGPoint dragPosition =  [flow convertPoint:view.center toView:self.scroll];

    // original grupe view

    UIGroupView * orgGrView = (UIGroupView *)flow.superview.superview;
    UIScrollView * orgScroll = (UIScrollView *)flow.superview;



    for (SEssentialsFlowLayout * destinationFlow in self.flows) {
        // destination grupe view
        UIGroupView * grView = (UIGroupView *)destinationFlow.superview.superview;
        UIScrollView * scroll = (UIScrollView *)destinationFlow.superview;

        if (flow != destinationFlow && grView.grupes.type == GrupeTypeEditable) {
            if (CGRectContainsPoint(destinationFlow.superview.superview.frame, dragPosition)) {

                view.center = [scroll convertPoint:dragPosition toView:scroll];

                // calculate cube space

                int numberOfCubeOnScreen = grView.frame.size.width / (grView.frame.size.height * grView.cubeWidth) ;
                int delta = grView.frame.size.width - (grView.frame.size.height * grView.cubeWidth * numberOfCubeOnScreen);
                float oneDelta = (float) delta/(numberOfCubeOnScreen );

                // destination grupe view
                int numberOfpage = ceil((grView.frame.size.height * grView.cubeWidth + oneDelta)* (destinationFlow.managedViews.count + 2) / grView.frame.size.width);
                destinationFlow.frame = CGRectMake(0, 0, grView.frame.size.width * numberOfpage, grView.frame.size.height * 0.68);

                scroll.contentSize = CGSizeMake(destinationFlow.frame.size.width, destinationFlow.frame.size.height);
                [grView.pageControll setNumberOfPages:numberOfpage];



                if (orgGrView.grupes.type == GrupeTypeNotEditable) {
                    // grabcube view
                    UICubeVeiw * oldCubeView = (UICubeVeiw *)view;

                    // create new cube and new cube view
                    Cube * newCube = [oldCubeView.cube copyCube];
                    UICubeVeiw * newCubeVew = [oldCubeView copyCubeView:oldCubeView.cube];

                    // copy new cube into old cube view
                    oldCubeView.cube = newCube;

                    // add new cube view on old flow
                    int newIndex = [flow.managedViews indexOfObject:view];
                    if (newIndex > 0 && newIndex< flow.managedViews.count) {
                        [flow unmanageSubview:view];
                        [flow addManagedSubview:newCubeVew atIndex:newIndex];

                        // move old cube view on new flow
                        [destinationFlow addManagedSubview:view];
                    }
                }
                else{

                    // original grupe view
                    int orgNumberOfpage = ceil((orgGrView.frame.size.height * grView.cubeWidth +oneDelta ) * (flow.managedViews.count ) / orgGrView.frame.size.width);
                    flow.frame = CGRectMake(0, 0, orgGrView.frame.size.width * orgNumberOfpage, orgGrView.frame.size.height * 0.68);

                    orgScroll.contentSize = CGSizeMake(flow.frame.size.width, flow.frame.size.height);
                    [orgGrView.pageControll setNumberOfPages:orgNumberOfpage];

                    [flow unmanageSubview:view];
                    [destinationFlow addManagedSubview:view];

                    [orgGrView.grupes removeCube:((UICubeVeiw *)view).cube];

                }

                needDeleteFavourites = YES;
            }
        }
    }

    NSLog(@"pozicija originala          :     %f ", orgGrView.grupes.positionIndex);
    if (orgGrView.grupes.positionIndex == 1 && needDeleteFavourites && orgGrView.grupes.cubes.count<1) {
        NSLog(@"remove");
        [self removeFavouritesFromView];
    }

    // move scroll view up and down
    if (dragScrollPosition.y < self.frame.size.height * 0.16) {
        NSLog(@"move down");
        if (!self.timerIsSet) {
            NSLog(@"move down 1");
            self.timerIsSet = YES;
            NSLog(@"move down 2");
            self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(moveScrollVeiwUp) userInfo:nil repeats:NO ];

        }
    }
    else if (dragScrollPosition.y > self.frame.size.height * 0.88) {
        if (!self.timerIsSet) {
            NSLog(@"move up");
            self.timerIsSet = YES;
            self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(moveScrollVeiwDown) userInfo:nil repeats:NO ];

        }
    }
    else{
        NSLog(@"move none");
        self.timerIsSet = NO;
        [self.timer invalidate];
        self.timer = nil;

        self.isFavouriteCurrentlyVisible = NO;
    }
}

大量のコードであることはわかっていますが、このウィンドウを移動すると奇妙なエラーが発生します。

pozicija originala          :     1.000000 
2013-09-23 20:20:31.772 BIView Mobile[659:60b] move down
2013-09-23 20:20:31.774 BIView Mobile[659:60b] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 2147483646 beyond bounds [0 .. 5]'
*** First throw call stack:
(0x2db25f53 0x382996af 0x2da5c5f3 0x94667 0x942a1 0x93f1f 0x92171 0x918bf 0x91759 0x3041d98d 0x302c83e3 0x30652eed 0x3028f28b 0x3028d9d3 0x302c6c41 0x302c65e7 0x3029ba25 0x3029a221 0x2daf118b 0x2daf065b 0x2daeee4f 0x2da59ce7 0x2da59acb 0x32734283 0x302fba41 0x71655 0x387a1ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException

これは、私が正しく理解している場合、どこかで無効なインデックスを取得し、それを使用して配列を調べる必要があることを意味します。

しかし、インデックスが許容値の範囲内にあるかどうかを常に確認します。

編集 :

アドバイスされたように、例外ブレークポイントを設定しましたが、残念ながらブレークポイントは次の場所で停止します:

int main(int argc, char *argv[])
{
    @autoreleasepool {
        return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
    }
}

役立つ場合は、スタック トレースを出力しました。

2013-09-24 11:48:10.683 BIView Mobile[890:60b] Uncaught exception: *** -[__NSArrayM objectAtIndex:]: index 2147483646 beyond bounds [0 .. 2]
2013-09-24 11:48:10.755 BIView Mobile[890:60b] Stack trace: (
0   CoreFoundation                      0x2db25f6b <redacted> + 154
1   libobjc.A.dylib                     0x382996af objc_exception_throw + 38
2   CoreFoundation                      0x2da5c5f3 <redacted> + 230
3   BIView Mobile                       0x000e34ef -[FlowPicker isLeftMost:inOrdering:] + 58
4   BIView Mobile                       0x000e3129 -[FlowPicker widenedSubviewExcludingView:inOrdering:] + 640
5   BIView Mobile                       0x000e2da7 -[FlowPicker indexOfPoint:currentBounds:currentIndex:inOrdering:excludingView:] + 118
6   BIView Mobile                       0x000e0ff9 -[FlowEdit changeEdit:] + 524
7   BIView Mobile                       0x000e0747 -[FlowEdit fireChangeEdit:afterTimeout:] + 342
8   BIView Mobile                       0x000e05e1 -[FlowEdit handleLongPress:] + 360
9   UIKit                               0x3041d98d <redacted> + 196
10  UIKit                               0x302c83e3 <redacted> + 1138
11  UIKit                               0x30652eed <redacted> + 48
12  UIKit                               0x3028f28b <redacted> + 218
13  UIKit                               0x3028d9d3 <redacted> + 282
14  UIKit                               0x302c6c41 <redacted> + 772
15  UIKit                               0x302c65e7 <redacted> + 666
16  UIKit                               0x3029ba25 <redacted> + 196
17  UIKit                               0x3029a221 <redacted> + 7096
18  CoreFoundation                      0x2daf118b <redacted> + 14
19  CoreFoundation                      0x2daf065b <redacted> + 206
20  CoreFoundation                      0x2daeee4f <redacted> + 622
21  CoreFoundation                      0x2da59ce7 CFRunLoopRunSpecific + 522
22  CoreFoundation                      0x2da59acb CFRunLoopRunInMode + 106
23  GraphicsServices                    0x32734283 GSEventRunModal + 138
24  UIKit                               0x302fba41 UIApplicationMain + 1136
25  BIView Mobile                       0x000bf55b main + 226
26  libdyld.dylib                       0x387a1ab7 <redacted> + 2
)
4

1 に答える 1

0

その返されたインデックス2147483646は、たまたまNSNotFound特定のアーキテクチャ上にあります。ステートメントの 1 つ (おそらく[flow.managedViews indexOfObject:view]) が返さNSNotFoundれているようです。確認する必要があります。

于 2013-09-23T18:58:45.103 に答える