È possibile aggiungere la visualizzazione dell'immagine come una visualizzazione secondaria di UITextView
.
Creare un IMAGEVIEW con un'immagine:
UIImageView *imageView = [[UIImageView alloc] initWithImage:yourImage];
[imageView setFrame:yourFrame];
[yourTextView addSubview:imageView];
Edit:
Per evitare l'uso di sovrapposizione (grazie @ Chris):
CGRect aRect = CGRectMake(156, 8, 16, 16);
[imageView setFrame:aRect];
UIBezierPath *exclusionPath = [UIBezierPath bezierPathWithRect:CGRectMake(CGRectGetMinX(imageView.frame), CGRectGetMinY(imageView.frame), CGRectGetWidth(yourTextView.frame), CGRectGetHeight(imageView.frame))];
yourTextView.textContainer.exclusionPaths = @[exclusionPath];
[yourTextView addSubview:imageView];
fonte
2012-11-07 05:49:40
Ma come si fa a evitare che l'ImageView da copre il testo nella visualizzazione testo? Come fai a far scorrere il testo attorno alla visualizzazione di immagini? –
CGRect aRect = CGRectMake (156, 8, 16, 16); [attachmentView setFrame: aRect]; UIBezierPath * exclusionPath = [UIBezierPath bezierPathWithRect: CGRectMake (CGRectGetMinX (attachmentView.frame), CGRectGetMinY (attachmentView.frame), CGRectGetWidth (internalTextView.frame), CGRectGetHeight (attachmentView.frame))]; internalTextView.textContainer.exclusionPaths = @ [exclusionPath]; [internalTextView addSubview: attachmentView]; –