0

いくつかの UIView があるところで、この奇妙な状況が発生しています。ユーザーがそれらの 1 つをタップすると、すべてがアニメーション化されます (基本的に Y 軸の位置が変更されます)。その後、いずれかのビューをタップしてスーパービューのすべてのサブビューを取得すると、2 つの UIImageView が追加されます。アプリには画像がまったくなく、作成する場所もありません。すべてのサブビューのログは次のとおりです。

最初のタップ:

2012-10-12 08:53:00.579 KIP_Acordion[1094:11603] <UIView: 0x71b96d0; frame = (5 5; 733 40); tag = 1; layer = <CALayer: 0x71b9730>>

2012-10-12 08:53:00.582 KIP_Acordion[1094:11603] <UIView: 0x71c2160; frame = (5 55; 733 40); tag = 2; layer = <CALayer: 0x71c20e0>>

2012-10-12 08:53:00.582 KIP_Acordion[1094:11603] <UIView: 0x71c4920; frame = (5 105; 733 40); tag = 3; layer = <CALayer: 0x71c49e0>>

2012-10-12 08:53:00.583 KIP_Acordion[1094:11603] <UIView: 0x71c6ed0; frame = (5 155; 733 40); tag = 4; layer = <CALayer: 0x71c6f90>>

2012-10-12 08:53:00.583 KIP_Acordion[1094:11603] <UIView: 0x71c93a0; frame = (5 205; 733 40); tag = 5; layer = <CALayer: 0x71c9320>>

2012-10-12 08:53:00.584 KIP_Acordion[1094:11603] <UIView: 0x71cb720; frame = (5 255; 733 40); tag = 6; layer = <CALayer: 0x71cb7e0>>

2 回目のタップ:

KIP_Acordion[1094:11603] <UIView: 0x71b96d0; frame = (5 5; 733 40); tag = 1; layer = <CALayer: 0x71b9730>>

2012-10-12 08:55:52.937 KIP_Acordion[1094:11603] <UIView: 0x71c2160; frame = (5 145; 733 40); tag = 2; layer = <CALayer: 0x71c20e0>>

2012-10-12 08:55:52.938 KIP_Acordion[1094:11603] <UIView: 0x71c4920; frame = (5 195; 733 40); tag = 3; layer = <CALayer: 0x71c49e0>>

2012-10-12 08:55:52.938 KIP_Acordion[1094:11603] <UIView: 0x71c6ed0; frame = (5 245; 733 40); tag = 4; layer = <CALayer: 0x71c6f90>>

2012-10-12 08:55:52.939 KIP_Acordion[1094:11603] <UIView: 0x71c93a0; frame = (5 295; 733 40); tag = 5; layer = <CALayer: 0x71c9320>>

2012-10-12 08:55:52.940 KIP_Acordion[1094:11603] <UIView: 0x71cb720; frame = (5 345; 733 40); tag = 6; layer = <CALayer: 0x71cb7e0>>

2012-10-12 08:55:52.941 KIP_Acordion[1094:11603] <UIImageView: 0x755ef60; frame = (731 403; 7 7); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; layer = <CALayer: 0x755efc0>>

2012-10-12 08:55:52.941 KIP_Acordion[1094:11603] <UIImageView: 0x755f010; frame = (731 403; 7 7); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; layer = <CALayer: 0x755f0b0>>

これは何が原因でしょうか?

編集:いくつかの追加情報:

各 UIView (親ビューと呼びます) には、UIView (タイトルバーと呼びます) と UIScrollView の 2 つのサブビューがあり、スクロール ビューの高さは 0.1 です。タイトルバーをタップすると、スクロール ビューの高さがリセットされ、アニメーション化されるため、それはサブビューです (現在は一連の UILabels と UITextfields)。他のすべての親ビューの位置は、表示されているスクロールビューの新しい高さに基づいてリセットされ、新しい位置にアニメーション化されます。

追加された UIImageViews が見つかった場所は、開いているスクロールビューを閉じるメソッドにあります。

- (void) closeAndCleanSections : (UIView* ) tappedSection {

    //get all the sections
    NSArray* allSections = [[tappedSection superview]subviews];

    //loop through all the sections
    for(int s=0; s<allSections.count; s++) {

        if([[allSections objectAtIndex:s] isKindOfClass:[UIView class]]) { 
            NSLog(@"%@", [allSections objectAtIndex:s]);
        }

    }//loop through sections
}

ビューをアニメーション化するために使用している方法は次のとおりです。

- (void) openSection : (UIView* ) sectionToOpen {

//get the scroll view (the hidden part)
NSArray* sectionViews = [sectionToOpen subviews];
UIScrollView* contentWrapper = [sectionViews objectAtIndex:1];

//get all the sections
NSArray* allSections = [[sectionToOpen superview] subviews];

//determine which section was tapped
int thisSectionID = sectionToOpen.tag;
NSString* storedID = [NSString stringWithFormat:@"Section_%i", thisSectionID];

//get it's opened and closed height
NSDictionary* thisSectionDictionary = [sections objectForKey:storedID];

float thisSectionOpenedHeight = [[thisSectionDictionary objectForKey:@"Section Opened Height"] floatValue];
float thisSectionClosedHeight = [[thisSectionDictionary objectForKey:@"Section Closed Height"] floatValue];

//adjust the parent scroll
CGRect svParentFrame = self.frame;
//take away the section's closed height
svParentFrame.size.height = svParentFrame.size.height - thisSectionClosedHeight;
//replace with the opened height (add 50.0 for padding)
svParentFrame.size.height = svParentFrame.size.height + thisSectionOpenedHeight + 50.0;
self.frame = svParentFrame;

//adjust the content wrapper's height
CGRect contentWrapperFrame = contentWrapper.frame;
contentWrapperFrame.size.height = thisSectionOpenedHeight;

//determine where all the sections need to be moved too
if (thisSectionID == 1) {
    for(int s=0; s<allSections.count; s++) {
        if (s>0) {

            UIView* thisSection = [allSections objectAtIndex:s];

            CGRect thisSectionFrame = thisSection.frame;

            thisSectionFrame.origin.y = thisSectionFrame.origin.y + thisSectionOpenedHeight + 10.0;

            //animate the view
            [UIView animateWithDuration:.5 delay:0 options:UIViewAnimationOptionCurveEaseOut

                             animations:^{
                                 thisSection.frame = thisSectionFrame;
                             }

                             completion:^ (BOOL finished) {
                             }
             ];
        }
    }

} else {

    float yDifference;
    float currentY;

    //move sections
    for(int s=0; s<allSections.count; s++) {

        //get the section
        UIView* thisSection = [allSections objectAtIndex:s];

        //get its frame
        CGRect thisSectionFrame = thisSection.frame;

        if (s+1 == thisSectionID) {

            //current y location
            currentY = thisSectionFrame.origin.y;
            yDifference = (currentY - 10.0);

            float newYLocation = 10.0;
            thisSectionFrame.origin.y = newYLocation;

        } else if (s+1 < thisSectionID) {

            //set new y
            float newYLocation = (s+1) * -80;
            thisSectionFrame.origin.y = newYLocation;


        } else {

            float newYLocation = (thisSectionFrame.origin.y + thisSectionOpenedHeight) - (currentY - 20.0);

            thisSectionFrame.origin.y = newYLocation;

        }

        //animate the sections
        [UIView animateWithDuration:.5 delay:0 options:UIViewAnimationOptionCurveEaseOut

                         animations:^{
                             thisSection.frame = thisSectionFrame;
                         }

                         completion:^ (BOOL finished) {
                         }
         ];

    }

}


//animate the section scroll view
[UIView animateWithDuration:.5 delay:0 options:UIViewAnimationOptionCurveEaseOut

                 animations:^{
                     contentWrapper.frame = contentWrapperFrame;
                 }

                 completion:^ (BOOL finished) {
                 }
 ];


}
4

0 に答える 0