我认为这是一个 Storyboard问题。
如何创建从表行到新 View Controller 的 Segue?
这是一张它应该是什么样子的图片。
我尝试将控件从表格拖动到底部的 View Controller ,但没有成功。如果我将 View Controller 嵌入到导航器中,我可以创建一个推送转场,但当您单击它时它不起作用。
这是我正在使用的代码,但首先我希望能够复制图片中的 Storyboard。无论如何,我希望当您单击表格行时弹出新的 View Controller 。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// Store Selection
[self setSelection:indexPath];
}
...
else if ([segue.identifier isEqualToString:@"updateToDoViewController"]) {
NSLog(@"segue to update");
// Obtain Reference to View Controller
UpdateTodoVC *vc = (UpdateTodoVC *)[segue destinationViewController];
// Configure View Controller
[vc setManagedObjectContext:self.managedObjectContext];
if (self.selection) {
// Fetch Record
NSManagedObject *record = [self.fetchedResultsController objectAtIndexPath:self.selection];
if (record) {
[vc setRecord:record];
}
// Reset Selection
[self setSelection:nil];
}
}
}
感谢您的任何建议。
最佳答案
您无法从“原型(prototype)”单元格中按住 Ctrl 键并拖动!您只能使用静态单元格来做到这一点。因此,您必须从 UITableViewController
按住 Ctrl 键并拖动到下一个 View Controller ,为其指定 updateToDoViewController
标识符,并以编程方式执行 segue:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
// Store Selection
[self setSelection:indexPath];
// Perform the segue with identifier: updateToDoViewController
[self performSegueWithIdentifier:@"updateToDoViewController" sender:self];
}
关于xcode - iOS/Xcode/ Storyboard : How can I segue from table row to modal view controller,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28143914/