1

I am creating a news app that has title, description, video and details. this is displayed on UIViewCell on TableView, when a user clicks on that particular cell, corresponding news is displayed as shown below

- (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];

}

The variables (which hold JSON data) are properly defined in NewsViewController and synthesised as follows

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

enter image description here Now, what I want is to add a video button as shown on the storyboard, so that a user can click it and be able to see details of corresponding video through modal /popup any suggestions or help?

cchana
  • 4,899
  • 3
  • 33
  • 43
user1430825
  • 121
  • 2
  • 10

2 Answers2

1

In the Storyboard, just use an Action segue on the UIButton and select modal. Control Drag from the button to the Video Details VC. Give that segue a name, let's say

playVideo

Then inside the prepareForSegue method in your PlayersViewController.m you just add this:

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

Also use unwind segues on the buttons 'Cancel' and 'Done' in your destination VC to return to the previous TVC. Alternatively you could also use dismissViewControllerAnimated: that will be passed to the calling VC.

Juan Catalan
  • 2,299
  • 1
  • 17
  • 23
  • thanks Juan, how do I pass data from that particular row to modal view? just like I did to details view – user1430825 Sep 03 '13 at 11:14
  • @user1430825: did I help you? Any other questions? – Juan Catalan Sep 03 '13 at 19:28
  • Still confused Juan, wish you could give an example – user1430825 Sep 03 '13 at 21:25
  • Where are you stuck? Tell me what are the problems? I have edited my post to better suit your particular example. – Juan Catalan Sep 03 '13 at 22:19
  • I got it, It is easier if you transfer the details from uiview cell because you can use indexpath.row for the selected row, however how do i tell the button to show that specific row? e.g. row 1 has news 1, row2 has news 2, row3 has news 3. I want that when a user click a button in row 1, he only gets video for that row, because at the moment, row 1 is giving me video 1, row 2 is giving me video 1 and row 3 is giving me video 1 (same video) – user1430825 Sep 04 '13 at 11:46
  • Got it finally! for anyone looking for that solution, i found it here http://stackoverflow.com/questions/9274494/how-to-know-the-uitableview-row-number – user1430825 Sep 04 '13 at 12:40
  • Did you use the prepareForSegue? – Juan Catalan Sep 04 '13 at 13:12
0

you should have a custom table view cell which will be handling actions and data on cell.

vignesh
  • 994
  • 10
  • 12
  • thanks but the viewcell is already providing more details, I want the button to bring up a pop up for that specific row – user1430825 Sep 04 '13 at 11:49