在我的我有一個屏幕,我通過不同的步驟添加按鈕,標籤等不同的組件。現在點擊後,我想刪除所有內容並顯示另一個視圖。 下面是一些代碼:如何刪除當前視圖中可見的所有內容,然後顯示不同的視圖?
-(void)estimateButtons:(NSString *)text andFrameX:(int)x andFrameY:(int)y andFrameW:(int)w andFrameH:(int)h
{
estimate = [UIButton buttonWithType:UIButtonTypeRoundedRect];
estimate.frame =CGRectMake(x,y,w,h);
//[estimate setTitle:text forState:UIControlStateNormal];
UIImage * buttonImage = [UIImage imageNamed:@"button_green_estimate.png"];
UIImage * strechableButtonImage = [buttonImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];
[estimate setBackgroundImage:strechableButtonImage forState:UIControlStateNormal];
[estimate addTarget:self action:@selector(estimateSelected:) forControlEvents:UIControlEventTouchUpInside];
[self.view addSubview:estimate];
}
-(void)estimateSelected:(UIButton *)b
{
[self.view removeFromSuperview];
graph = [[SFNDoorBarGraphVC alloc]initWithNibName:@"SFNDoorBarGraphVC" bundle:nil];
[graph.view setCenter:CGPointMake(350, 660)];
[self.view addSubview:graph.view];
}
有了這個代碼的清除一切,但它不是我的顯示新視圖的內容是圖。
工作正常!非常感謝。有沒有辦法從刪除中保存視圖,但不是休息。 – Ashutosh 2011-04-12 21:24:14