오늘 저는 앱에서 현재 재생중인 노래의 가사를 자동 스크롤하도록 일부 텍스트를 가져 오려고했는데 animateWithDuration 메소드를 사용하여 스크롤이 제대로 작동하도록하는 대답을 얻었습니다. 다음 코드를 사용하면 textView 배경과 같은 색으로 textView의 80 %를 덮어 버리는 것을 발견하기 전까지는 환상적으로 작업했습니다. 덮어 쓴 영역 (시뮬레이터와 테스트 장치 모두)을 스 와이프하면 상자 (또는 무엇이든)가 사라지고 모든 텍스트가 정상적으로 나타납니다. animateWithDuration의 메소드 호출이라는 것을 알고 있습니다. 주석 처리 했으므로 텍스트는 프로젝트에 포함되지 않은 상태로 빌드하고 실행할 때 다루지 않습니다. 또한 Interface Builder에 들어가서 textView의 색상을 흰색으로 변경했습니다 (보기의 다른 모든 배경과 함께 검은 색이었습니다). 검은 색 배경도 포함하고 있는지 확인하십시오. 내가 흰색으로 바꿨을 때, 텍스트는 여전히 덮여 있었고, 이번에는 흰색 상자로 덮여있었습니다. 다시 한번 textView를 숨기고 노래의 가사를 채우는 것은 처음입니다. 내가 덮은 지역을 스쳐 지나간 후에는 방해물을 연주하는 노래가 나타나지 않습니다. 처음 훔쳐 볼 때까지. 여기에 내가 사용하고 코드 ...animateWithDuration이 UITextView에서 문제를 일으켰습니다.
// set the textView to start at the top of the document
[textView setContentOffset:CGPointZero];
CGPoint scrollPoint = textView.contentOffset;
// set the scroll point to the length of the text view, so it knows how far down to go
scrollPoint.y= [textView.text length];
다음은 텍스트가
`// animate down to that point at the rate of the length of the song minus 20 seconds (so the lyrics can catch up to the song)
[UIView animateWithDuration:(self.myMusicPlayer.duration - 20)
delay:0
options:UIViewAnimationOptionAllowUserInteraction
animations:^(void) {self.textView.contentOffset = scrollPoint;}
completion:nil];`
을 적용받을 원인이 무엇이며 여기에 이전의 및 박스 영역을 강타 후 사진의입니다.
사람은 텍스트 또는 나는 그것을 제거하기 위해 무엇을 할 수 있는지를 덮고 어떤 생각을 가지고? 또는 animateWithDuration 이외의 다른 메서드를 사용하여 가사를 자동 스크롤 할 수있는 다른 방법이 있습니까?
텍스트보기에 가사를 채우는 데 사용하는 코드는 다음과 같습니다.
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { // determine which row was clicked
NSUInteger row = [indexPath row];
// get the song name from the array at the position clicked
NSString *rowString = [songNames objectAtIndex:row];
// load the lyrics for the song played into the textView
// load the text file for the song selected
NSString *lyrics = [[NSBundle mainBundle] pathForResource:rowString ofType:@"txt"];
NSString *fileContents = [NSString stringWithContentsOfFile:lyrics];
// set the textView to load the lyric sheet for the song selected
self.textView.text = fileContents; // more after this, but this is all that I'm doing with the textView
편집 : 나는 그것을 이해하지 못하고 있지만 글쎄, 난, 텍스트를 덮고있는 블랙 박스의 문제를 해결했습니다. 가사로 더 잘 흐르도록 텍스트 파일을 포맷하는 동안 내 캐리지 리턴뿐만 아니라 줄 바꿈으로 인해 텍스트가 덮히게됩니다. 텍스트 파일의 내용을 삭제하고 원본을 다시 붙여 넣어 텍스트가 덮히지 않게했습니다. 이제 텍스트를 덮지 않고 텍스트 파일의 텍스트 서식을 지정하는 방법을 찾는 것이 목표였습니다. 어떤 제안?
이렇게하면 문제가 해결 될지 모르지만 텍스트보기의 색을 지우도록 설정하십시오. 'self.textView.backgroundColor = [UIColor clearColor];' –
훌륭한 제안이지만, 불행히도 작동하지 않았습니다. –