这是programmtically当播放按钮被按下显示的UIViewController
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemPlay
target:self
action:@selector(playaudio:)];
systemItem1.style = UIBarButtonItemStyleBordered;
-(void) playaudio: (id) sender
{
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"theme"
ofType:@"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath:filePath];
audioPlayer = [[AVAudioPlayer alloc]
initWithContentsOfURL:fileURL error:nil];
audioPlayer.currentTime = 0;
[audioPlayer play];
[fileURL release];
UIViewController* flipViewController = [[UIViewController alloc]init];
[self.view addSubview:flipViewController.view];
}
不使用协议和委托方法我可以用presentmodalviewcontroller显示的UIViewController当播放按钮被按下 – user1120133 2012-01-29 22:22:38
代表团是推荐的方式,但你可以使用通知为好。 – Beppe 2012-01-29 23:44:01
通知你可以请告诉我如何当按下播放按钮时可以使用通知来显示UIViewController。 – user1120133 2012-01-30 00:31:43