Cat*_*ber 25 iphone uitableview ios5
我正在使用故事板在ios5中创建一个应用程序.我有一个嵌入在导航控制器中的tableviewcontroller,当你点击tableviewcontroller中的单元格时,应该将有关该单元格主题的一些细节传递给详细视图.我使用plist来填充tableview和详细视图.我没有使用故事板就做到了这一点,但想学习如何使用故事板.我有seque从tableviewcontroller转到我的详细视图.
我的seque代码是:
- (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;
}
}
Run Code Online (Sandbox Code Playgroud)
谢谢你的帮助.
M. *_*edi 67
我遇到了同样的问题(由于缺乏iOS5的经验).
事实证明,这是一个iOS5 SDK的示例应用程序,它有一个表格视图,在点击表格单元格时使用segues:"Simple Drill Down".
您可以在表格单元格中设置segue,并在storyboard文件中为其指定名称.
- (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];
}
}
Run Code Online (Sandbox Code Playgroud)
小智 12
我遇到了同样的问题,遵循Ray Wenderlich教程的部分内容,发现你需要选择表格单元格并按Ctrl键拖动到你的viewcontroller.然后调用 performSegueWithIdentifier
在didSelectRowAtINdexPath
.
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"mySegueId" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"prepareForSegue: %@", segue.identifier );
if ([segue.identifier isEqualToString:@"mySegueId"])
{
DetailController *detailController = segue.destinationViewController;
detailController.delegate = (id)self;
detailController.selected = selectedRow;
}
}
Run Code Online (Sandbox Code Playgroud)
我遇到了同样的问题,但还没有用故事板解决它。但是,我认为 Segue 应该从单元格开始,而不是整个 tableviewcontroller。如果您使用原型单元,这可能会起作用 - 但我不知道代码创建的单元类型。也将不胜感激有关此主题的任何帮助。
编辑: http://kurrytran.blogspot.com/2011/10/ios-5-storyboard-and.html上的教程表明不存在 segue 解决方案,您仍然需要在代码中转换到详细视图。我不知道这有多正确,但我会这样做,直到有人向我展示纯粹的故事板/segue 解决方案;)。
归档时间: |
|
查看次数: |
27997 次 |
最近记录: |