0

我正在开发一个 iPad 应用程序,这是我第一次充分利用弹出视图。我将弹出视图用作带有类别的菜单,并且只有一个带有视频的屏幕。当用户选择一个类别时,'FeaturedViewController' 必须使用新的 playlistId 重新加载视图。

当用户选择一个类别时,很容易做到: double playlistId = [[playlists.items objectAtIndex:indexPath.row] playlistId];

但是如何在 FeaturedViewController 中获取 playlistId 并重新加载视图?

4

2 回答 2

0

看:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// load new playlist
BCPlaylist *playlist = (BCPlaylist *) [playlists.items objectAtIndex:indexPath.row];
NSNumber *key = [NSNumber numberWithDouble:playlist.playlistId];
NSLog(@"Key: %@", key);
FeaturedViewController *nextView = [[FeaturedViewController alloc] initWithNibName:nil bundle:nil];
nextView.PLID = key;
[self.navigationController pushViewController:nextView animated:YES];
[nextView release];
}

Key NSlogs 正确,但我根本没有从 FeaturedViewController 中的 nextView.PLID 得到响应。

于 2011-08-02T10:39:10.923 回答
0

在您的 FeaturedViewController.m

- (void)viewDidLoad 
{
     //create reference of your delegate
    YourAppDelegate rootApp = (YourAppDelegate *)[[UIApplication sharedApplication]delegate];

     double playlistId = [[[[rootApp playlists] items] objectAtIndex:indexPath.row] playlistId ];
    [super viewDidLoad];
}

已编辑

或者您可以在 FeaturedViewController 中定义一个属性并在此 VC 中分配值,例如:

FeaturedViewController  nextView = [[FeaturedViewController alloc] initWithNibName:@"FeaturedViewController" bundle:nil];
 //below lineset the value of property and you can pass value to nextView
    nextView.playlistId = [[playlists.items objectAtIndex:indexPath.row] playlistId]; ;
    [self.navigationController pushViewController:nextView animated:YES];

希望它能让您了解访问委托的变量

于 2011-07-29T13:18:24.887 回答