問題描述
我正在使用故事板在 ios5 中創(chuàng)建一個(gè)應(yīng)用程序.我在導(dǎo)航控制器中嵌入了一個(gè) tableviewcontroller,當(dāng)您單擊 tableviewcontroller 中的單元格時(shí),應(yīng)將有關(guān)該單元格主題的一些詳細(xì)信息傳遞給詳細(xì)信息視圖.我使用 plist 來填充表格視圖和詳細(xì)信息視圖.我在不使用情節(jié)提要的情況下做得很好,但想學(xué)習(xí)如何使用情節(jié)提要.我已經(jīng)從 tableviewcontroller 轉(zhuǎn)到我的詳細(xì)視圖.
I'm creating an app in ios5 using storyboards. I have a tableviewcontroller embedded in a navigation controller and when you click on the cells in the tableviewcontroller some detail about that cell topic should be passed to a detail view. I use a plist to populate the tableview and the detail view. I've done this fine without using storyboard but want to learn how to use storyboard. I have seque going to my detail view from the tableviewcontroller.
我的序列代碼是:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"DetailViewControllerSeque"])
{ DetailViewController *detailViewController = [segue destinationViewController];
NSString *path = [[NSBundle mainBundle] bundlePath];
NSString *finalPath = [path stringByAppendingPathComponent:@"questList.plist"];
NSArray *tempArray = [finalPath valueForKey:@"description"];
NSString *descriptionString = [tempArray valueForKey:@"description"];
detailViewController.detailDescriptionText.text = descriptionString;
}
}
感謝您的幫助.
推薦答案
我遇到了同樣的問題(由于缺乏 iOS5 經(jīng)驗(yàn)).
I was having the same problem (from lack of experience with iOS5).
事實(shí)證明,這是一個(gè)帶有 iOS5 SDK 的示例應(yīng)用程序,它有一個(gè)表格視圖,當(dāng)點(diǎn)擊表格單元格時(shí)使用 segues:Simple Drill Down".
It turns out that is an example app with the iOS5 SDK which has a table view that uses segues when a table cell is tapped : "Simple Drill Down".
https://web.archive.org/web/20130513140140/http://developer.apple.com:80/library/ios/#samplecode/SimpleDrillDown/Introduction/Intro.html
您確實(shí)在表格單元格處設(shè)置了轉(zhuǎn)場,并在情節(jié)提要文件中為其命名.
You do set the segue at the table cell and give it a name in the storyboard file.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
/*
When a row is selected, the segue creates the detail view controller as the destination.
Set the detail view controller's detail item to the item associated with the selected row.
*/
if ([[segue identifier] isEqualToString:@"ShowSelectedPlay"]) {
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
DetailViewController *detailViewController = [segue destinationViewController];
detailViewController.play = [dataController objectInListAtIndex:selectedRowIndex.row];
}
}
這篇關(guān)于如何將序列 ios5 故事板 uitableview 中的數(shù)據(jù)傳遞到詳細(xì)視圖的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!