這是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