0
我已經使用圖像選擇器插入在文本視圖的庫中的圖像的文本視圖與插入圖像之後,如何移動/跳光標下一行到圖像視圖中
在pickeDelegate didFinishPickingImage
方法
imgview = [[UIImageView alloc] initWithImage:image];
NSString *messageText = [[NSString alloc]init];
messageText = messageView.text;
CGSize s = [messageText sizeWithFont:[UIFont systemFontOfSize:15] //define your textview font size
constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT) // lineBreakMode:UILineBreakModeWordWrap];
CGRect frame = CGRectMake(0.0f, s.height+10, 50, 50);//use YourImageView. height and width
imgview.frame=frame;
//[imgview setFrame:CGRectMake(0, 0, 30,30) ];
[messageView addSubview:imgview];
而實現的邏輯使用跟隨着委託方法邏輯
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
{
if ([text isEqualToString:@"\n"]) {
}
else
{
NSString *yourstring = [[NSString alloc]init];
yourstring = textView.text;
CGSize s = [yourstring sizeWithFont:[UIFont systemFontOfSize:15] //define your textview font size
constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT) // - 40 For cell padding
lineBreakMode:UILineBreakModeWordWrap];
CGRect frame = CGRectMake(0.0f, s.height+10, 50, 50);//use YourImageView. height and width
imgview.frame=frame;
}
return YES;
}
在最後文本的末尾添加圖像
但每次光標剛圖像視圖開始之前,
但i need to jump/ move the cursor after the image when ever i added the image, jus like as folows,
我requrement是用戶可在文本視圖中輸入文字,他可以在文本視圖與添加圖像然後從下一行後的圖像,他可以能夠再次輸入文字,
就像我們在這堆過流盒連接相似圖片
插入圖片後,他可能能夠提前再次輸入文字,
如何做到這一點任何幫助..謝謝
我剛纔的問題:Adding Images to UITextView