[問題] 背景音樂&觸控滑頁
您好,我想請問二個問題
第一個是我在第一頁加入一首背景音樂
不過當翻到第二頁的時候,這首音樂還是會繼續播放
感覺上是要寫一個翻頁停止的指令
不過不曉的要怎麼處理
找到的教學也是要點按鈕才能停止的那種方法。
下面是我的原始碼(我用AVFoundation)
- (void)viewDidAppear:(BOOL)animated
{
[NSTimer scheduledTimerWithTimeInterval:0.0 target:self
selector:@selector(play) userInfo:nil repeats:NO];
-(void)play{
NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MUSIC.wav"
,[[NSBundle mainBundle] resourcePath]]];
NSError *error;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
audioPlayer.numberOfLoops= 1;
[audioPlayer play];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return YES;
}
第二個問題是關於用手指滑頁
我有找到xcode裡內建的 swipe gesture recognizers
可以用手指控制翻上頁或下頁
不過我的頁面是希望左右滑動,不過怎麼調整他就是會上下滑頁
(而且好像不太靈敏)
(ps,我的畫面設定是橫的,不過看網路教學就算是直的他也是上下滑頁)
想請問該如何改變設定,
還是否有更好的方法或是其它的寫法可以完成這個手續
懇請高手解惑,卡在這二個地方好幾天了~~
謝謝~~~~
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 114.47.124.53
→
01/03 00:04, , 1F
01/03 00:04, 1F
→
01/03 00:05, , 2F
01/03 00:05, 2F
→
01/03 01:07, , 3F
01/03 01:07, 3F
→
01/03 01:11, , 4F
01/03 01:11, 4F
→
01/03 01:12, , 5F
01/03 01:12, 5F
→
01/03 01:13, , 6F
01/03 01:13, 6F
→
01/03 01:15, , 7F
01/03 01:15, 7F
→
01/06 01:27, , 8F
01/06 01:27, 8F
→
01/06 01:28, , 9F
01/06 01:28, 9F
→
01/06 01:29, , 10F
01/06 01:29, 10F
→
01/06 01:30, , 11F
01/06 01:30, 11F
→
01/06 01:32, , 12F
01/06 01:32, 12F
→
01/07 00:07, , 13F
01/07 00:07, 13F
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章