我在服务器中存储了一些文本值。我成功地获取了该文本值并存储到本地数据库文件中。然后将该值添加到数组中。当我将该数组值显示到 UITextView 时。但是 textview 显示所有值。我有点击索引的按钮。如果我单击第一个按钮,我需要显示第一个文本。然后下一个按钮。如果我单击每个按钮,它会显示所有值。
代码:
-(void)dbClicked:(id)sender{
[mmageView setImage:[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:[productimg_array objectAtIndex:[sender tag]-1]]]]];
[self.view addSubview:mmageView];
UITapGestureRecognizer *singletapp=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(singleTap:)];
singletapp.numberOfTapsRequired=1;
[mmageView addGestureRecognizer:singletapp];
}
- (void)singleTap:(UIGestureRecognizer *)singletap {
UITextView *txt=[[UITextView alloc]initWithFrame:CGRectMake(50, 50, 150,150)];
NSMutableString *string = [NSMutableString string];
for(int i=0;i<[descript_array count];i++){
NSLog(@"descript array is is %d",i);
txt.text = [descript_array objectAtIndex:i];
}
[self.view addSubview:txt];
}
NS日志:
descript array is is 14
string is the name is image with black color
the name is image with black color
the name is image with white color
the name is
the name is
the name is
the name is
the name is
the name is
the name is
the name is
the name is
descript array is is 15
string is the name is image with black color
the name is image with black color
the name is image with white color
the name is
the name is
the name is
the name is
the name is
the name is
the name is
the name is
the name is