我想添加一個ViewController到我的TableView單元,但它在測試時沒有顯示出來。添加ViewController作爲UITableViewCell中的子視圖 - 沒有顯示
PhotoLocation是一個UIViewController子類。我在StoryBoard上創建了一個View Controller,並配置了一堆UILabels,UITextFields,UISwitch等。 PhotoLocation與該StoryBoard視圖控制器相關聯,其標識符是PhotoLocation。在一個單獨的控制器 - UITableViewController,我有一個工作的TableView與細胞填充各種信息,我想添加PhotoLocation VC作爲每個單元格的子視圖。 (注意:PhotoLocation是一個自由大小的VC,大小爲210x100)。
在我cellForRowAtIndexPath
方法我做了以下內容:
// snip code above which sets up the cell and performs various other things
PhotoLocation *photoLocation_ = [self.storyboard instantiateViewControllerWithIdentifier:@"PhotoLocation"];
[photoLocation_.view setFrame:CGRectMake(115, 0, 210, 109)];
[cell.contentView addSubview:photoLocation_.view];
return cell;
當我運行應用程序的子視圖不會在細胞中出現。這裏有什麼我失蹤?
交換和使用筆尖做的伎倆,謝謝。但是請注意,我確實將一個VC的加載作爲一個子視圖作爲一個單元格工作。我把它加載到單元格中,但是在選擇了單元格中的任何東西之後,我得到了一個運行時錯誤(我認爲是錯誤的訪問)。無論如何,筆尖是要走的路,再次感謝! – ElasticThoughts 2012-04-11 15:01:46