我在我的應用程序中有一個滾動視圖。 如果我點擊一個頁面上的按鈕,則添加一個子視圖。我想在用戶滾動視圖時刪除此子視圖。該功能被稱爲:從不存在的視圖中刪除子視圖
-(void) DisableViews {
[Annimation removeFromSuperview];
NSLog(@"scroll");
}
我得到的NSLog很多次,但風景也就是子視圖,當我回來的頁面。
我想這會發生,因爲子視圖的視圖不是當前的視圖,所以我不能刪除子視圖。
是否有任何可能從子視圖的任何視圖中刪除子視圖?
編輯: ViewController.h
@interface ViewController : UIViewController {
//...
UIView *Annimation;
}
@property (nonatomic,retain) UIView *Annimation;
實現:
ViewController.m
#import "ViewController.h"
#import "AppDelegate.h"
@implementation ViewController
@synthesize Annimation;
//...
- (void) Bild1ButtonKlickt{
Annimation = [[UIView alloc]initWithFrame:CGRectMake(0.0, 0.0, 320.0, 480.0)];
Annimation.backgroundColor = [UIColor blackColor];
[self.view addSubview:Annimation];
}
NSLog相當無用。使它成爲'NSLog(@「remove℅@」,[動畫描述]);'。 – 2013-03-09 18:52:47
我的NSLog只查看這個函數是否被調用 – Pascal 2013-03-10 12:50:26
它還應該告訴「Animation」是否爲非零。 – 2013-03-10 17:19:32