iPhone 3.1.3 (3g iPhone)에서 non-nil을 어떻게 반환 할 수 있습니까? NSClassFromString (@ "MPMoviePlayerViewController")은 3.1.3 (iPhone)의 EVEN이 아닌 값을 반환합니다.
- (BOOL) isIOS3_2OrAbove
{
Class mplayerControllerClass = NSClassFromString(@"MPMoviePlayerViewController");
if(mplayerControllerClass != nil)
{
NSLog(@"MPMoviePlayerViewController not showing NIL! It is: %@\n",[mplayerControllerClass description]);
return YES;
}
else
{
NSLog(@"MPMoviePlayerViewController is showing NIL!\n");
return NO;
}
}
나는이 반환받을 :
MPMoviePlayerViewController not showing NIL! It is: MPMoviePlayerViewController
방법이 가능하게 일어날 수 있습니까? USB를 통해 장치를 실행하는 Xcode 3.2.3을 사용 중입니다.
는 여기를 호출하는 코드입니다
NSString *movieName = @"litedefault.mp4";
if ([self isIOS3_2OrAbove] == YES)
{
movieName = @"litedefault_3_2.mp4";
}
NSString *moviePath = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:movieName];
moviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL fileURLWithPath:moviePath ]];
moviePlayer.movieControlMode = MPMovieControlModeHidden;
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(set_up_views:) name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer];
if ([self isIOS3_2OrAbove] == YES)
{
NSLog(@"IS iOS3.2 or above\n");
moviePlayer.view.frame = CGRectMake(0, 0, 320, 480);
[window addSubview:moviePlayer.view];
[window makeKeyAndVisible];
}
else
{
NSLog(@"IS BELOW iOS3.2\n");
}
[moviePlayer play];
내가 3.2을 통해 모든 장치를 테스트하고자하고 있음을 이해, 그래서 내가 예를 들어, UI_USER_INTERFACE_IDIOM
을 테스트하고 있지 않다. 보시다시피 3.2 이상에서는 MPMoviePlayerController를 뷰에 추가해야합니다.
아이디어가 있으십니까?
부록 :
우리가 (이전 아이폰 OS 릴리스의) 개인 API되지 않은 클래스를 확인해야 함을 보인다. 필자는 UILongPressGestureRecognizer (실제로는 존재하지만 3.1.3에서는 private 임)를 테스트했고, 결과가 0이 아닌 것을 얻었다.
OKAY .... 그래서이 질문은 기본적으로 변경되었습니다. 누구나 내가 확인할 수있는 API를 알 수 있습니다. 3.1.3 (또는 이전 버전)입니까?
URGH!
OMGosh! 나는 그렇게 쉬울 것이라고 생각하지 않았다. 카페인 없이는 프로그래밍해서는 안된다. 감사! – Jann