我有一個viewcontroller設置爲scrollview委託(scrollview是viewcontroller的子視圖),當我把[scrollview removeFromSuperview]; viewcontroller和scrollview都被刪除,我只剩下一個空的窗口。我怎樣才能刪除滾動視圖?
如何只刪除滾動視圖?
編輯::::
這是我的ViewController的一部分.H
@interface QuartzViewController : UIViewController <UIScrollViewDelegate> {
這是我的視圖控制器的.m
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
UIInterfaceOrientation o = self.interfaceOrientation;
if ((o == UIInterfaceOrientationPortrait) || (o == UIInterfaceOrientationPortraitUpsideDown)) {D = 1;pagingScrollView.delegate = nil;[pagingScrollView removeFromSuperview];[self resurrectPaging];}
if ((o == UIInterfaceOrientationLandscapeLeft) || (o == UIInterfaceOrientationLandscapeRight)) {D = 2;pagingScrollView.delegate = nil;[pagingScrollView removeFromSuperview];[self resurrectPaging];}}
-(void)resurrectPaging {
CGRect F;
F = [self frameForPagingScrollView];
pagingScrollView = [[UIScrollView alloc] initWithFrame:F];
[SELF addSubview:pagingScrollView];
[self setPaging];}
- (void)viewDidLoad {
[self.view addSubview:SELF];
D = 1;
CGRect F;
F = [self frameForPagingScrollView];
pagingScrollView = [[UIScrollView alloc] initWithFrame:F];
[self setPaging];}
- (void)setPaging {
if (D == 1) {
CGRect F;
F = [self frameForPagingScrollView];
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor whiteColor];
pagingScrollView.showsVerticalScrollIndicator = NO;
pagingScrollView.showsHorizontalScrollIndicator = NO;
pagingScrollView.contentSize = CGSizeMake(F.size.width * [self pdfPageCount], F.size.height);
pagingScrollView.delegate = self;
pagingScrollView.clipsToBounds = YES;
pagingScrollView.bounces = YES;
self.view = pagingScrollView;
recycledPages = [[NSMutableSet alloc] init];
visiblePages = [[NSMutableSet alloc] init];
[self tilePages];
[pagingScrollView addSubview:self.isvP];}
else if (D == 2) {
CGRect F;
F = [self frameForPagingScrollView];
pagingScrollView.pagingEnabled = YES;
pagingScrollView.backgroundColor = [UIColor redColor];
pagingScrollView.showsVerticalScrollIndicator = NO;
pagingScrollView.showsHorizontalScrollIndicator = NO;
pagingScrollView.contentSize = CGSizeMake(F.size.width * [self pdfPageCount], F.size.height);
pagingScrollView.delegate = self;
pagingScrollView.clipsToBounds = YES;
pagingScrollView.bounces = YES;
self.view = pagingScrollView;
recycledPages = [[NSMutableSet alloc] init];
visiblePages = [[NSMutableSet alloc] init];
[self tilePages];
[pagingScrollView addSubview:self.isvL];}}
基本原因,我該怎麼去除的一部分那麼再次添加我的滾動視圖是因爲當設備方向改變爲橫向時,我的橫向子視圖位於錯誤的位置(x,y)。
但說如果我開始在風景isvL是在正確的地方,所以我知道我得到的代碼正確。去風景螺絲在我的pagingScrollView isvL的x,y位置!
什麼語言,框架? – 2010-08-23 22:01:29
iphone sdk對不起,我忘了 – user422241 2010-08-23 22:15:01
你能發表一些代碼嗎?這裏沒有足夠的信息來給出合理的答覆。 – 2010-08-23 22:24:05