我有兩個的TextView滾動型我想,上單擊任何的TextView的應該在詳細視圖中希望的信息UIScrollWith可點擊文本
詮釋J = 0;
for (int i = 0; i < rowOne.count; i++) {
if (j==1) {
j++;
}
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
UIView*subView=[[UIView alloc ]initWithFrame:frame];
[self.scrollView addSubview:subView];
Book*book=[rowOne objectAtIndex:i];
CGRect myframe=CGRectMake(107, 46, 258, 128);
UITextView*textView=[[UITextView alloc] initWithFrame:myframe];
book.bookID=bookidone;
textViewOneDescription=book.fulltext;
[subView addSubview:textView];
//[backViewButton addSubview:textView];
NSString* myid=book.bookID;
NSLog(myid);
NSString*text1=book.teaser;
fulltextone=book.fulltext;
textView.font=[UIFont fontWithName:@"Times New Roman" size:16];
NSString*mytext=book.teaser;
mytext = [mytext stringByReplacingOccurrencesOfString:@"\n" withString:@""];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext = [mytext stringByReplacingOccurrencesOfString:@"å" withString:@"å"];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext = [mytext stringByReplacingOccurrencesOfString:@"ø" withString:@"ø"];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext = [mytext stringByReplacingOccurrencesOfString:@"æ" withString:@"æ"];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext = [mytext stringByReplacingOccurrencesOfString:@"Æ" withString:@"Æ"];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext = [mytext stringByReplacingOccurrencesOfString:@"Ø" withString:@"Ø"];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext = [mytext stringByReplacingOccurrencesOfString:@"Å" withString:@"Å"];
mytext = [mytext stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
textView.text=mytext;
//testButton.tag=j;
//[testButton addTarget:self action:@selector(tappedItemAtIndex:)forControlEvents:UIControlEventTouchUpInside];
UIButton*headingButton=[UIButton buttonWithType:UIButtonTypeCustom];
headingButton.frame=CGRectMake(20, 10, 300, 35);
NSString*headingbuttontitle=book.title;
//NSString*headingbuttontitle=j;
headingbuttontitle = [headingbuttontitle stringByReplacingOccurrencesOfString:@"\n" withString:@""];
headingbuttontitle = [headingbuttontitle stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
[headingButton setTitle:headingbuttontitle forState:UIControlStateNormal];
//[headingButton setTitle:[NSString stringWithFormat:@"%d",j] forState:UIControlStateNormal];
[headingButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
headingButton.tag=j;
[headingButton addTarget:self action:@selector(tappedItemAtIndex:) forControlEvents:UIControlEventTouchUpInside];
headingButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
headingButton.titleLabel.font = [UIFont boldSystemFontOfSize:20 ];
UIButton*myImageButton=[UIButton buttonWithType:UIButtonTypeCustom];
myImageButton.frame=CGRectMake(20, 46, 90, 127);
NSString*thumb2=book.thumbimgurl;
thumb2 = [thumb2 stringByReplacingOccurrencesOfString:@"\n" withString:@""];
thumb2 = [thumb2 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
UIImage *image2 = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:thumb2]]];
myImageButton.tag=j;
[myImageButton setBackgroundImage:image2 forState:UIControlStateNormal];
// myImageView.image=[UIImage imageNamed:@"thumb.jpg"];
[myImageButton addTarget:self action:@selector(tappedItemAtIndex:) forControlEvents:UIControlEventTouchUpInside];
[subView addSubview:myImageButton];
j++;
CGRect myframe1=CGRectMake(502, 46, 150, 128);
Book*book1=[rowOneSecond objectAtIndex:i];
UITextView*textViewtwo=[[UITextView alloc] initWithFrame:myframe1];
NSString*mytext1=book1.teaser;
textViewTwoDescription=book1.fulltext;
book1.fulltext=fulltexttwo;
book1.bookID=bookid;
testButton1.tag=j;
[testButton1 addTarget:self action:@selector(tappedItemAtIndex:)forControlEvents:UIControlEventTouchUpInside];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"\n" withString:@""];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"å" withString:@"å"];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"ø" withString:@"ø"];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"æ" withString:@"æ"];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"Æ" withString:@"Æ"];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"Ø" withString:@"Ø"];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
mytext1 = [mytext1 stringByReplacingOccurrencesOfString:@"Å" withString:@"Å"];
mytext1 = [mytext1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
textViewtwo.text=mytext1;
textViewtwo.font=[UIFont fontWithName:@"Times New Roman" size:16];
UIButton*headingButton1=[UIButton buttonWithType:UIButtonTypeCustom];
headingButton1.frame=CGRectMake(408, 10, 300, 37);
[headingButton1 setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
NSString*headingbutton1title=book1.title;
headingbutton1title = [headingbutton1title stringByReplacingOccurrencesOfString:@"\n" withString:@""];
headingbutton1title = [headingbutton1title stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
headingButton1.titleLabel.font = [UIFont boldSystemFontOfSize:20 ];
[headingButton1 setTitle:headingbutton1title forState:UIControlStateNormal];
// [headingButton1 setTitle:[NSString stringWithFormat:@"%d",j] forState:UIControlStateNormal];
headingButton1.tag=j;
// [headingButton1 setTitle:j forState:UIControlStateNormal];
[headingButton1 addTarget:self action:@selector(tappedItemAtIndex:) forControlEvents:UIControlEventTouchUpInside];
headingButton1.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
UIButton*myImageButton1=[UIButton buttonWithType:UIButtonTypeCustom];
myImageButton1.frame=CGRectMake(408, 46, 90, 127);
NSString*thumb1=book1.thumbimgurl;
thumb1 = [thumb1 stringByReplacingOccurrencesOfString:@"\n" withString:@""];
thumb1 = [thumb1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
UIImage *image1 = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:thumb1]]];
myImageButton1.tag=j;
[myImageButton1 setBackgroundImage:image1 forState:UIControlStateNormal];
// myImageView.image=[UIImage imageNamed:@"thumb.jpg"];
[myImageButton1 addTarget:self action:@selector(tappedItemAtIndex:) forControlEvents:UIControlEventTouchUpInside];
[subView addSubview:myImageButton1];
[subView addSubview:textViewOneLink];
[subView addSubview:headingButton];
[subView addSubview:headingButton1];
[subView addSubview:textViewtwo];
//[subView addSubview:textView];
}
代碼爲什麼你需要的TextView那裏呢? –
你用UITextView Delegates試過了嗎? –
textview顯示數據 – Ali