Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7840173
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:41:06+00:00 2026-06-02T15:41:06+00:00

I have a text view and I need to add image in text view.The

  • 0

I have a text view and I need to add image in text view.The text view idea can be assume as text and image and after image text and so on.I can add image on text view but my problem is when I again edit my text view ,the text go behind the image.What I want is suppose if the image is below my cursor position and I am editing the text so my image should also be shift front or back.Please help me how can I achieve the functionality of shifting image on editing text.My app deployment target is 5.0 so we can include the new features provided in ios 5.0.

In the image it is shown how on editing the text the text go behind the image view.That is why I need to shift my image view.

Please Please help me.I am stuck here.

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T15:41:09+00:00Added an answer on June 2, 2026 at 3:41 pm

    Dude Use my code…

    - (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, 320.0f, 20);//use YourImageView. height and width 
        YourImageView.frame=frame;
    }
    return YES;
    }
    

    Let Me know. If you find any Difficulty…

    Edited
    *Additional….*

    //imgSwipe2 is my UIImgaeView you can use your imageview. May Be i forgot to release some object and i am sure that you can handle but it's working fine,
    
    -(void)textViewDidChangeSelection:(UITextView *)textView
     {
      NSRange range = textView.selectedRange;
    if(range.location<textView.text.length)
    {
        NSString * firstHalfString = [txtView.text substringToIndex:range.location]; 
    
        CGSize s = [firstHalfString sizeWithFont:[UIFont systemFontOfSize:15] 
                               constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT)  // - 40 For cell padding
                                   lineBreakMode:UILineBreakModeWordWrap];   
    
        if(s.height<imgSwipe2.frame.origin.y)
        {
            // You can use this code any number of image
    
            imgSwipe2.frame = CGRectMake(imgSwipe2.frame.origin.x, s.height, imgSwipe2.frame.size.width, imgSwipe2.frame.size.height);  
    
    
        }
        else
        {
            // Do what ever you want to do
    
            NSString * firstString1 = textView.text;                
            CGSize s = [firstString1 sizeWithFont:[UIFont systemFontOfSize:15] 
                                constrainedToSize:CGSizeMake(self.view.bounds.size.width - 40, MAXFLOAT)  // - 40 For cell padding
                                    lineBreakMode:UILineBreakModeWordWrap];   
            imgSwipe2.frame = CGRectMake(imgSwipe2.frame.origin.x, s.height, imgSwipe2.frame.size.width, imgSwipe2.frame.size.height);
    
    
        }   
      }
    }
    

    Hope,this will help you…Enjoy…

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a View to that I need to add some text. The used
I have a lsit view and i that i need to add some text.
In my application,i have text view with long text. i need text wrapping like
I need to have various text view on a single line. And I want
I have Text( http://www.mywebsite.com ) in a view, in which i need to provide
I need to add two text view to the list view as shown in
In my view I need to add (dynamically) text inputs and I need to
http://dl.dropbox.com/u/24856/android_issue.PNG i have a text view on top running into the relative layout with
I have a GTK# Text View with word wrap and scroll bars turned on.
I have Auto completed text view,i want to filter the items present in the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.