我已经添加了一个 UIViewController 的视图和一个按钮来滚动视图作为子视图......现在我如何释放 UIViewController 的所有实例......这是一个附加的图像
在视图中,每个 uiview 上方都有一个按钮,用于进一步导航....
现在我想从滚动视图中释放 uiview 并删除按钮 ...这是我添加子视图的方法 -(void)AddOneButton:(NSInteger)myButtonTag { lastButtonNumber = lastButtonNumber + 1;
if ((lastButtonNumber == 1) || ((lastButtonNumber%2) == 1)) {
btnLeft = 8;}
else if ((lastButtonNumber == 2) || ((lastButtonNumber%2) == 0)) {
btnLeft = 162;
}
CGRect frame1 = CGRectMake(btnLeft, btnTop, 150, 150);
CGRect frame2 = CGRectMake(btnLeft, btnTop, 150, 150);
UIButton *Button = [UIButton buttonWithType:UIButtonTypeCustom];
Button.frame = frame1;
Button.tag = myButtonTag;
[Button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside];
[Button setBackgroundColor:[UIColor clearColor]];
[Button setBackgroundImage:[UIImage imageNamed:@"WaitScreen.png"] forState:UIControlStateHighlighted];
[Button setBackgroundImage:[UIImage imageNamed:@"WaitScreen.png"] forState:UIControlStateSelected];
if(categoryType==1)
{
MultiChoiceThumbViewControllerobj = [[MultiChoiceThumbViewController alloc] initWithPageNumber:myButtonTag+1];
MultiChoiceThumbViewControllerobj.view.frame=frame2;
MultiChoiceThumbViewControllerobj.lblCounter.text=[NSString stringWithFormat:@"%d of %d",myButtonTag+1,flashCardsId.count];
MultiChoiceThumbViewControllerobj.lblQuestion.text=[flashCardText objectAtIndex:myButtonTag];
[myScrollView addSubview:MultiChoiceThumbViewControllerobj.view];
}
[myScrollView addSubview:Button];
}
使用此代码,滚动视图的子视图计数为 = 96。
我在 dealloc 中使用此方法来删除子视图,但它没有释放 UIvicontroller
for(UIView *subview in [myScrollView subviews])
{
[subview removeFromSuperview];
NSLog(@"Subviews Count=%d",myScrollView.subviews.count);
}
我如何释放uiviewcontroller的???