檢查我的UIView是否已經顯示在屏幕上的最佳方法是什麼?我有UISplitViewController,我試圖在點擊tableViewCell後在自定義UIView中顯示細節。我想要做的就是避免重複已經顯示的視圖,或者如果可能的話關閉現在並顯示新的視圖。檢查我的UIView是否已被顯示的最佳方法是什麼?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
NSLog(@"did select row at index path %ld",(long)indexPath.row);
InvoiceDetailsVC *detailsVC = [[InvoiceDetailsVC alloc]initWithFrame:CGRectMake(321, 0,708, 709)];
//here I would like to check if my detailsVC has already been shown
//if not I would like to display in that way
[self.splitViewController.view addSubview:detailsVC];
}
感謝所有幫助 問候
它不適合我,因爲我嘗試加載UIView而不是UIViewController。 InvoiceDetailsVC是一個自定義的uiview。所以這個方法對我的自定義uiview不可見。在我的故事板中,我將UISplitViewController添加爲UITabBarController的tabBarItem,並且因爲我無法與detailsViewController進行通信,因爲splitviewcontroleller必須位於應用程序的根目錄。我嘗試將選定的UITAbleviewCell的細節顯示爲splitviewcontroller的子視圖。我的問題還有其他解決方案嗎? – sonoDamiano