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];

今度は別のIBActionでactivityimageViewを削除したいのですが、XcodeはそのSubViewを認識していません...何かアイデアはありますか?!

4

1 に答える 1

2

あなたの

UIImageView *activityImageView 

.h ファイルと IBAction で、次のようなコードを記述します

[activityImageView removeFromSuperView];
于 2013-01-23T11:22:38.300 に答える