2011-08-09 32 views

回答

0

如何..

if(myBOOL == YES) { 

    ADifferentViewController * vc = (ADifferentViewController *)[[ADifferentViewController alloc]init]; 
    [self.navigationController pushViewController:vc animated:NO]; 
    [vc release]; 

} 
+0

我不想推視圖控制器到堆棧上。我只想替換當前的視圖。 –

+0

該問題是設置表視圖的背景,而不是將其他視圖放在其上。 – Akshay

+0

哦,對不起。誤解了這個問題。低估的人不要太過挑剔。 SH T!! – Louie

2

取而代之的是UITableViewController,你可以把兩個視圖裏面UIViewController

@interface MyViewController : UIViewController <UITableViewDelegate> { 
    UITableView *tableView; 
    UIWebView *anotherView; 
} 

...

if (someBool) { 
    tableView.hidden = YES; 
    anotherView.hidden = NO; 
} else { 
    tableView.hidden = NO; 
    anotherView.hidden = YES; 
} 
0

可能是這樣的:

if (myBool == YES) { 

UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)]; 
[self.view addSubview:myView]; 

} 

我們擺脫它:

[myView removeFromSuperview]; 

當然還有很多其他的方法...

即使是:self.view = myView;

9

我實現下面的方法在我的表視圖控制器子類重新加載其背景。

- (void)reloadBackground 
{ 

     if(myBool) 
     { 

    //load the view to be displayed from a nib   
    NSArray* nibs = [[NSBundle mainBundle] loadNibNamed:@"EmptyView" owner:self options:nil]; 
      UIView* emptyView = [nibs objectAtIndex:0]; 
      self.tableView.backgroundView = emptyView; 
      self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone; 
     } 
     else 
     { 
      self.tableView.backgroundView = nil; 
      self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine; 
     } 

} 

HTH,

阿克沙伊

0

使用一個UIView,而不是如果的UITableViewController ....從.h文件中的變化 的UITableViewController來的UIViewController連接視圖文件的所有者 從廈門國際銀行

將UITableView放在UIView中...將另一個UIView放在空白視圖中 並將其背景色設置爲Tablevi EW顏色

如果bool如果爲真 然後顯示的tableview 和隱藏空白查看其他 隱藏的tableview 顯示空白視圖