2011-08-25 3 views

답변

0

나는 그것을 알아 냈다.

평소처럼 UIWebView를 만듭니다.

이 같은 배열 만들기 :

self.youtubeVideos = [NSArray arrayWithObjects: @"http://localhost/screen.php?video=McHosr_98r0", 
        @"http://localhost/plasma/screen.php?video=TY1lNAEzZP0", 
        @"http://localhost/plasma/screen.php?video=Ml-rxMwcaf0", 
        @"http://localhost/plasma/screen.php?video=N70DLM8Az_8", 

        nil]; 
currentVideoIndex = 0; 

그런 다음 인터페이스 빌더에서 버튼을 생성하고이로를 연결 :

-(IBAction)gotoAddress:(id) sender { 

[downloadSourceField resignFirstResponder]; 

downloadSourceField.text = [youtubeVideos objectAtIndex:currentVideoIndex]; 
currentVideoIndex++; 
if (currentVideoIndex >= youtubeVideos.count) { 
    currentVideoIndex = 0; 
} 


NSURL *url = [NSURL URLWithString:[downloadSourceField text]]; 
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url]; 

//Load the request in the UIWebView. 
[webView loadRequest:requestObj]; 
[downloadSourceField resignFirstResponder]; 
} 

배열를 뒤로 이동을, 이것을 사용 :

downloadSourceField.text = [youtubeVideos objectAtIndex:currentVideoIndex]; 
currentVideoIndex--; 
if (currentVideoIndex < 0) {  
    currentVideoIndex = youtubeVideos.count-1; 
} 
} 

매력처럼 작동합니다.

+0

최종 블록 (뒤로 이동)을 제외하고는 <0 인 경우 currentVideoIndex를 youtubeVideos.count로 설정해야합니다. – jrtc27

관련 문제