作者热门文章
- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
如何将对象从详细信息披露分流器传递到详细信息 View Controller ?对此有什么建议或快速修复吗?理想情况下,我想创建这样的方法:
[self performSegueWithIdentifier:@"showDetail" sender:self passObject:object];
原因是“准备继续”似乎只有在我按下详细信息披露指示器之前的单元格时才会被调用。我将如何创建一个像上面这样的方法来创建下面准备的效果?
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
id object = [_objects objectAtIndex:indexPath.row];
[[segue destinationViewController] setDetailItem:object];
}
我已经尝试像这样创建 UIStoryboardSegue 的子类,但遇到了两个问题。
@implementation masterToDetail
-(void)performSegueWithIdentifier:(NSString*)identifier sender:(id)sender passObject:(id)object{
[self.destinationViewController setDetailItem:object];
[self performSegueWithIdentifier:identifier sender:sender];
}
-(void)performSegueWithIdentifier:(NSString*)identifier sender:(id)sender{
//What code should go here? Issue one
}
-(void)perform{
//Second issue, the compiler will crash and say I need to override perform.
}
最佳答案
我通过完全放弃 segue idea 的子类解决了这个问题。我删除了自定义 segue 并将推送 segue(从 tableviewcontrollre)推送到我的详细 View Controller 。然后我创建了一个实例变量 NSIndexPath* _ipath;
我的代码如下:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath{
_ipth = indexPath;
[self performSegueWithIdentifier:@"showDetail" sender:self];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
NSLog(@"prepping");
if ([[segue identifier] isEqualToString:@"showDetail"]) {
NSLog(@"in if");
id object = [_objects objectAtIndex:_ipth.row];
[[segue destinationViewController] setDetailItem:object];
}
}
这可以让 segue 为正确的单元格工作做好准备。
关于iphone - 从详细信息披露按钮 segue 传递对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11197295/
我可以渲染“披露”按钮图形吗?它不是一个按钮。我想将图像添加到自定义渲染的单元格中,但不确定如何获取图像。 如何单独渲染图像。 最佳答案 这是一个Photoshop template file与大多数
是否有一种简单的方法来自定义可展开项目的显示三角形? 我尝试删除它并在单击自定义披露指示器时调用 [outlineView ExpandItem:X],但所有性感的内置动画都不起作用。有没有什么技巧可
我是一名优秀的程序员,十分优秀!