0
UIWebView에서 배열의 다음 URL을로드하게하는 버튼이 있습니다.UIWebView의 배열에서 다음 웹 페이지를로드하는 UIButton
가장 좋은 방법은 무엇입니까?
모든 예제 코드는 높이 평가 될 것입니다.
감사합니다.
UIWebView에서 배열의 다음 URL을로드하게하는 버튼이 있습니다.UIWebView의 배열에서 다음 웹 페이지를로드하는 UIButton
가장 좋은 방법은 무엇입니까?
모든 예제 코드는 높이 평가 될 것입니다.
감사합니다.
나는 그것을 알아 냈다.
평소처럼 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 인 경우 currentVideoIndex를 youtubeVideos.count로 설정해야합니다. – jrtc27