假設我有3段文本。我想用UITextView來顯示它。我有一個Next和Previous按鈕來幫助我循環。解決這個問題的最好方法是什麼?我正在嘗試一些代碼..但它不適用於我.. 實際上,我需要像這樣顯示: 如果我點擊下一個按鈕,我需要顯示像this.page of 1 of 3和page 2 of 3和page 3. 3如果單擊後退按鈕我需要顯示像3 this.page 3 3 2頁,第1頁的3如何使用ios中的next和previous UIButton在UITextView中顯示不同的文本片段
-(void)btnClicked:(UIButton*)btn
{
int totalcount=3;
if(slokaText.hidden==NO)
{
if (btn.tag==1)
{
NSLog(@"%lu", (unsigned long)[textStr count]);
if (counter<[textStr count]-1) {
counter++;
NSLog(@"%i", counter);
descriptionLbl1.text= [NSString stringWithFormat:@"%@", [textStr objectAtIndex:counter]];
NSLog(@"counter is :%d",counter);
countLabel.text=[NSString stringWithFormat:@"page %d of %d",counter,totalcount];
}
}
else
{
if (counter>1)
{
counter--;
descriptionLbl1.text= [NSString stringWithFormat:@"%@", [textStr objectAtIndex:counter]];
NSLog(@"counter is :%d",counter);
countLabel.text=[NSString stringWithFormat:@"page %d of %d",counter,totalcount];
}
}
}
else if (slokaMeaning.hidden==NO)
{
if (btn.tag==1)
{
NSLog(@"%lu", (unsigned long)[textStr1 count]);
if (counter<[textStr1 count]-1) {
counter++;
NSLog(@"%i", counter);
descriptionLbl2.text= [NSString stringWithFormat:@"%@", [textStr1 objectAtIndex:counter]];
NSLog(@"counter is :%d",counter);
countLabel.text=[NSString stringWithFormat:@"page %d of %d",counter,totalcount];
}
}
else
{
if (counter>1)
{
counter--;
descriptionLbl2.text= [NSString stringWithFormat:@"%@", [textStr1 objectAtIndex:counter]];
NSLog(@"counter is :%d",counter);
countLabel.text=[NSString stringWithFormat:@"page %d of %d",counter,totalcount];
}
}
}
else if (meaning.hidden==NO)
{
if (btn.tag==1)
{
NSLog(@"%lu", (unsigned long)[textStr2 count]);
if (counter<[textStr2 count]-1)
{
counter++;
NSLog(@"%i", counter);
descriptionLbl3.text= [NSString stringWithFormat:@"%@", [textStr2 objectAtIndex:counter]];
NSLog(@"counter is :%d",counter);
countLabel.text=[NSString stringWithFormat:@"page %d of %d",counter,totalcount];
}
}
else
{
if (counter>1)
{
counter--;
descriptionLbl3.text= [NSString stringWithFormat:@"%@", [textStr2 objectAtIndex:counter]];
NSLog(@"counter is :%d",counter);
countLabel.text=[NSString stringWithFormat:@"page %d of %d",counter,totalcount];
}
}
}
}
你遇到了什麼錯誤surya – 2015-02-23 09:15:41
如果我點擊下一個按鈕顯示像這樣:第1頁3和第2頁3 ..如果我點擊返回按鈕顯示是這樣的:第2頁共3頁第1頁共3頁第0頁共3頁。 。像這樣...... – Surya 2015-02-23 10:10:34