我添加了一個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