我添加了一个UIViewController的视图和一个按钮,滚动型的子视图...现在我该怎样释放UIViewController的所有实例...这里是在视图中附加的图像alt text http://i25.tinypic.com/2m4yefa.png如何将uiview作为子视图添加到scrollview中?
每一个的UIView有一个按钮,在它进一步导航....
现在我想释放的UIView的,并从滚动视图删除按钮...这里是我的方法来添加子视图 - (空)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];
}
使用此代码subviews scrollview的计数为96。
我已经使用这个方法的dealloc删除子视图,但它没有公布UIvicontroller的
for(UIView *subview in [myScrollView subviews])
{
[subview removeFromSuperview];
NSLog(@"Subviews Count=%d",myScrollView.subviews.count);
}
我如何释放UIViewController的???
非常感谢它的工作...请你以更详细的方式 – 2009-08-29 14:34:56
解释你错过了这个[MultiChoiceThumbViewControllerobj版本] 行后面的这行[subViewControllers addObjet:MultiChoiceThumbViewControllerobj]; – 2009-08-29 14:35:45