當我按前一個按鈕時,它不會產生任何效果。下一個按鈕工作正常,但上一個按鈕不顯示以前的圖像。我使用scroll view
加載圖片:使用按鈕單擊在滾動視圖中移動前一圖像
- (IBAction)next{
int arraycount = [appDelegate.articles count];
for (int nextIndex = [pageControl currentPage]; nextIndex < arraycount; nextIndex++) {
if (self.scrollView.contentOffset.x <= self.scrollView.frame.size.width) {
CGRect frame;
frame.origin.x = self.scrollView.contentOffset.x + self.scrollView.frame.size.width;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
[self.scrollView scrollRectToVisible:frame animated:YES];
pageControlBeingUsed = YES;
}
}
}
-(IBAction)previousButtonAction
{
int arraycount = [appDelegate.articles count];
NSLog(@" arraycount : %d", arraycount);
NSLog(@" [pageControl currentPage] : %d", [pageControl currentPage]);
for (int nextIndex = [pageControl currentPage]; nextIndex>arraycount; nextIndex--) {
if (self.scrollView.contentOffset.x >= self.scrollView.frame.size.width) {
CGRect frame;
frame.origin.x = self.scrollView.contentOffset.x + self.scrollView.frame.size.width;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
[self.scrollView scrollRectToVisible:frame animated:YES];
pageControlBeingUsed = YES;
}
}
}
的做的問題!上面編輯的答案。 – user1107725
DOH提到從循環下一個索引值,其中提到 – ader
它的工作完美謝謝,如果我想爲以前然後可能只使用遞減標誌 – user1107725