NSNotificationCenter

注册页面---------------

//在通知中心注册通知

[[NSNotificationCenterdefaultCenter]addObserver:selfselector:@selector(receive:)name:@"receive"object:nil];

[play.btnaddTarget:selfaction:@selector(playMusic)forControlEvents:UIControlEventTouchUpInside];

// Do any additional setup after loading the view.

}

-(void)receive:(NSNotification*)noti

{

play.btn.selected=NO;

dic= noti.object;

NSString*path = [[NSBundlemainBundle]pathForResource:[dicobjectForKey:@"name"]ofType:@"mp3"];

NSURL*url = [NSURLfileURLWithPath:path];

play1= [[AVAudioPlayeralloc]initWithContentsOfURL:urlerror:nil];

play.current.text=[selfchangeTime:play1.currentTime];

play.duration.text= [selfchangeTime:play1.duration];

self.navigationItem.title= [dicobjectForKey:@"name"];

}

使用界面-----------

//给消息中心发通知

[[NSNotificationCenterdefaultCenter]postNotificationName:@"receive"object:[arrobjectAtIndex:indexPath.row]];

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容