我有一个父视图控制器和一个子视图控制器,我需要让正确的儿童视图控制器从一个按钮将信息传递回父视图控制器tableViewCell
文本高亮显示。
在父视图控制器,当细胞被窃听,单元格文本高亮显示,儿童视图控制器弹出在屏幕上,并播放了所选择的歌曲。 然而,在儿童视图控制器有一个快退和快进按钮,当按下时,无论是那些与父视图控制器再次显示单元格文本需要现在比以前的重要性被突出显示为不同的小区 。
所以,我已经添加了适当的委托样板代码到每个视图控制器,但我不知道最好的信息从子视图控制器抢发回父视图控制器,以及如何使用。
子视图控制器 :
-(IBAction)indexChanged:(UISegmentedControl *)sender
{
NSURL *musicFile = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Blip_Select" ofType:@"wav"]];
AVAudioPlayer *click = [[AVAudioPlayer alloc] initWithContentsOfURL:musicFile error:nil];
switch (self.segmentedControl.selectedSegmentIndex)
{
case 0:
[click play];
[click play];
[musicPlayer skipToPreviousItem];
break;
case 1:
[click play];
if ([musicPlayer playbackState] == MPMusicPlaybackStatePlaying) {
[musicPlayer pause];
} else {
[musicPlayer play];
}
break;
case 2:
[click play];
[click play];
[musicPlayer skipToNextItem];
default:
break;
}
}
我想补充一点,在上述各开关语句里面,但我不知道究竟会效果最好 ?
因为这是它看起来像父视图控制器 :
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
AlbumsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"Cell" forIndexPath:indexPath];
MPMediaItem *rowItemAlbum = [[albumsArrayForTVC objectAtIndex:indexPath.section] representativeItem];
NSString *albumDetailTitle = [rowItemAlbum valueForProperty:MPMediaItemPropertyAlbumTitle];
MPMediaQuery *albumMPMediaQuery = [MPMediaQuery albumsQuery];
MPMediaPropertyPredicate *albumPredicate = [MPMediaPropertyPredicate predicateWithValue: albumDetailTitle forProperty: MPMediaItemPropertyAlbumTitle];
[albumMPMediaQuery addFilterPredicate:albumPredicate];
NSArray *albumTracksArray = [albumMPMediaQuery items];
MPMediaItem *rowItemSong = [[albumTracksArray objectAtIndex:indexPath.row] representativeItem];
NSString *songTitle = [rowItemSong valueForProperty:MPMediaItemPropertyTitle];
cell.textLabel.text = songTitle;
cell.textLabel.highlightedTextColor = [UIColor brownColor];
return cell;
}
我知道我要补充某种方法,并重新加载表,但我不知道去了解这一点的最好办法。 有任何想法吗? 谢谢!