故事板Segue与弹出按钮和detailview

时间:2013-09-03 09:51:05

标签: ios objective-c uitableview uistoryboardsegue

我正在创建一个包含标题,说明,视频和详细信息的新闻应用。 当用户点击它时,它会显示在TableView上的UIViewCell上 特定单元格,相应的新闻显示如下:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    NewsViewController *newsdetail = [[NewsViewController alloc] initWithNibName:@"NewsDetailView" bundle:nil];
    self.newsdetails = detail;
    [detail release];

    newsdetails.title = [NSString stringWithFormat:@"%@",[titleData objectAtIndex:indexPath.row]];
    newsdetails.itemID = [NSString stringWithFormat:@"%@",[NewsIds objectAtIndex:indexPath.row]];

    [self.navigationController pushViewController:newsdetails animated:YES];

}

变量(包含JSON数据)在NewsViewController中正确定义并合成如下

NSMutableArray *NewsIds;
NSMutableArray *titleData;
NSMutableArray *descriptionData; etc

enter image description here 现在,我想要的是添加一个视频按钮,如故事板上所示,以便用户可以点击它,并能够通过模态/弹出窗口查看相应视频的详细信息 有什么建议或帮助吗?

2 个答案:

答案 0 :(得分:1)

在Storyboard中,只需在UIButton上使用Action segue并选择模态。控制从按钮拖动到视频详细信息VC。给那个segue一个名字,让我们说

playVideo

然后在PlayersViewController.m中的prepareForSegue方法内添加:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"playVideo"]) {
    // set properties on your destinationVieController to pass the data you need
    }
}

还可以在目标VC的“取消”和“完成”按钮上使用展开segue返回上一个TVC。或者你也可以使用dismissViewControllerAnimated:它将被传递给调用VC。

答案 1 :(得分:0)

您应该有一个自定义表格视图单元格,它将处理单元格上的操作和数据。