2013-01-23 156 views
0

即時特林刪除添加的子視圖,但我不能這樣做... 我添加子視圖在一個UIButton刪除添加子視圖

//Create the first status image and the indicator view 
UIImage *statusImage = [UIImage imageNamed:@"loader_01.png"]; 
UIImageView *activityImageView = [[UIImageView alloc] 
            initWithImage:statusImage]; 


//Add more images which will be used for the animation 
activityImageView.animationImages = [NSArray arrayWithObjects: 
            [UIImage imageNamed:@"loader_01.png"], 
            [UIImage imageNamed:@"loader_02.png"], 
            [UIImage imageNamed:@"loader_03.png"], 
            [UIImage imageNamed:@"loader_04.png"], 

            nil]; 


//Set the duration of the animation (play with it 
//until it looks nice for you) 
activityImageView.animationDuration = 0.3; 


//Position the activity image view somewhere in 
//the middle of your current view 
activityImageView.frame = CGRectMake(
            self.view.frame.size.width/2 
            -statusImage.size.width/2, 
            self.view.frame.size.height/2 
            -statusImage.size.height/2, 
            statusImage.size.width, 
            statusImage.size.height); 

//Start the animation 
[activityImageView startAnimating]; 


//Add your custom activity indicator to your current view 
[self.view addSubview:activityImageView]; 

現在我想用另一種去除activityimageView IBAction ...但Xcode不知道SubView ... 任何想法?

+1

地方你'的UIImageView * activityImageView'在.h文件中,並在IBAction爲寫代碼像IBAction爲寫這個代碼'[ activityImageView removeFromSuperView];' –

+0

好的...謝謝...它的作品...;) – Loralon

+0

正如你有解決方案,我添加我的評論作爲answer.please接受它 –

回答

2

地方你

UIImageView *activityImageView 

在.h文件中,並在這樣

[activityImageView removeFromSuperView]; 
相關問題