开发者

Remove a subview from UIScrollView

开发者 https://www.devze.com 2023-03-22 13:35 出处:网络
i wa开发者_JAVA百科nt to remove currencyViews (tableViews) that are not more needed. i can change dynamically them, and if i had 6 currencyViews and now are 4 , those 2 (not showed) still exist. how c

i wa开发者_JAVA百科nt to remove currencyViews (tableViews) that are not more needed. i can change dynamically them, and if i had 6 currencyViews and now are 4 , those 2 (not showed) still exist. how can i remove them ?

  - (void)loadScrollViewWithPage:(int)page {


        if (page < 0) return;
        if (page >=  numberOfCurrencyViews) return;

        // replace the placeholder if necessary

        CurrencyViewController *controller = [self.currencyControllers objectAtIndex:page];

        if ((NSNull *)controller == [NSNull null]) {

            controller = [[CurrencyViewController alloc] initWithPageNumber:page];

            controller.delegate = self;

            [self.currencyControllers replaceObjectAtIndex:page withObject:controller];

            [controller release];
        }

        // add the controller's view to the scroll view
        if (nil == controller.view.superview)
         {
            CGRect frame = scrollView.frame;
            frame.origin.x = frame.size.width * page;
            frame.origin.y = 0;
            controller.view.frame = frame;
            [scrollView addSubview:controller.view];
         }    


    }


You can remove a subview from a view using something to the extent of:

[controller.view removeFromSuperview];


[myScrollView.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号