开发者

Remove a subview from UIScrollView

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜