나는 2 개의 전망으로 이루어져있는 간단한 app가있다. 상단보기에는 가속도계 대표가 있습니다. 탑 뷰가 화면 상에있을 때 사용자가 흔들 때. pushviewcontroller가 호출되고 하위보기가 나타납니다. 문제는 subview가 appeard 일 때, 나는 그것을 흔들어, 여전히 흔들기 동작을 잡아서 오류가 발생합니다. 도와주세요. 미리 감사드립니다.다른보기에서 흔들리는 동작이 있습니까?
플레이 방법은 전화 및 비디오, 완료과 pushViewController가 호출되고 하위 뷰가 아래나타납니다
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {
const float violence = 1.2;
static BOOL beenhere;
BOOL shake = FALSE;
if (beenhere) return;
beenhere = TRUE;
if (acceleration.x > violence || acceleration.x < (-1* violence))
shake = TRUE;
if (acceleration.y > violence || acceleration.y < (-1* violence))
shake = TRUE;
if (acceleration.z > violence || acceleration.z < (-1* violence))
shake = TRUE;
if (shake) {
[self playSound:@"suzu"];
if ([[NSUserDefaults standardUserDefaults] boolForKey:@"noVib"] == NO) {
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);
}
[[UIAccelerometer sharedAccelerometer] setDelegate:nil];
[self presentModalViewController:mMoviePlayer animated:YES];
[self play];
}
모든 movieplayer 물건을 처리하는 클래스입니다.
- (void) initPlayer{
if (mMoviePlayer != nil){
[mMoviePlayer release];
}
mMoviePlayer = [[MoviePlayerViewController alloc] initWithContentURL:[self createURL]];
[[NSNotificationCenter defaultCenter] removeObserver:mMoviePlayer
name:MPMoviePlayerPlaybackDidFinishNotification object:mMoviePlayer.moviePlayer];
[mMoviePlayer.moviePlayer setShouldAutoplay:NO];
mMoviePlayer.moviePlayer.backgroundView.backgroundColor = [UIColor blackColor];
mMoviePlayer.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
mMoviePlayer.moviePlayer.controlStyle = MPMovieControlStyleNone;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlayBackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:mMoviePlayer.moviePlayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePreloadDidFinish:)
name:MPMoviePlayerLoadStateDidChangeNotification
object:mMoviePlayer.moviePlayer];
- (void) moviePlayBackDidFinish:(NSNotification*)notification
{
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO];
[[NSNotificationCenter defaultCenter] removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:mMoviePlayer.moviePlayer];
[self dismissModalViewControllerAnimated:YES];
[mMoviePlayer release];
mMoviePlayer = nil;
[self toNext];
}
확인 감사합니다. 방금 코드 몇 개를 추가했습니다. –
modalViewController 속성이 사용자의 mMoviePlayer와 같은지 테스트해야합니다. 그렇다면 처음 아이디어에서와 같이 새 변수를 선언하는 대신 사용할 수 있습니다. 첫 번째 솔루션은 예상대로 작동해야합니다. –
흔들어서 && mMoviePlayer 조건을 변경했습니다. 따라서 하위보기에서는 흔들기 동작을 잡지 못합니다. 하지만 하위보기가 나타납니다 때 캐시는 subview.in에 표시됩니다, 다른 말로하면, 나는 다시 메인 메뉴로 돌아가서, 내가 다시 흔들어, 이번에는 하위보기 즉시 subivew의 이전 내용을 보여준 다음 quichly로 변경 올바른보기. 무슨 뜻이에요 ? –