Text position in UITextView

How can i get position of special word in UIText View in iphone SDK ?

I don't think there's any direct method for determining the x-y coordinates of a particular run of text (whether selected or not) in UITextView. If I needed to do this, I would use an iterative algorithm. E.g., a simplified algorithm, which assumes the target text is one word, which can't be broken and can be rendered on a single line, might go something like this:
1) Find the range of the target in the full text using [rangeOfString:options:range:|http://developer.apple.com/iphone/library/documen tation/Cocoa/Reference/Foundation/Classes/NSStringClass/Reference/NSString.html#//appleref/occ/instm/NSString/rangeOfString:options:range:];
2) From the end of the range (1), get the substring of the full text that ends in the target using [substringToIndex:|http://developer.apple.com/iphone/library/documentation/Coco a/Reference/Foundation/Classes/NSStringClass/Reference/NSString.html#//apple_ref/doc/uid/20000154-substringToIndex];
3) Get the bounding rectangle of the substring (2) using [sizeWithFont:constrainedToSize:lineBreakMode:|http://developer.apple.com/iphon e/library/documentation/UIKit/Reference/NSStringUIKit_Additions/Reference/Reference.html#//appleref/doc/uid/TP40006893-CH3-SW9];
4) Remove words from the end of the substring (2) until the height of the bounding rectangle (3) is reduced. The length of the shortened substring should give you the index at the start of the line which contains the target; Save the reduced bounding rectangle as rUpper;
5) Get the bounding rectangle of the line which begins at the start index (4), rLine, as well as the bounding rectangle of the target, rTarget, using [sizeWithFont:constrainedToSize:|http://developer.apple.com/iphone/library/docu mentation/UIKit/Reference/NSStringUIKit_Additions/Reference/Reference.html#//appleref/doc/uid/TP40006893-CH3-SW8];
6) The target bounding rectangle, r, relative to the bounds of the text view object should then be obtained as:
r.origin.x = rLine.size.width - rTarget.size.width;
r.origin.y = rUpper.size.height;
r.size.width = rTarget.size.width;
r.size.height = rTarget.size.height;
\- Ray

Similar Messages

  • How to get text position in a pdf?

    I need to get text position such has width, height, x, y and base position in a pdf.
    Can one help me to work further.

    i solved PDEForm issue thank you. Now i need to get the text from PDEElement.
    Can you help for this?
      PDEElement pdeElement;
        ASInt32 numElems = PDEContentGetNumElems (pdeContent);
        ASFixedRect bBox;
        for (ASInt32 i = 0; i < numElems; i++) {
            pdeElement = PDEContentGetElem (pdeContent, i);
            if (PDEObjectGetType((PDEObject)pdeElement) == kPDEForm)
                PDEForm form = (PDEForm)pdeElement;
                PDEContent content = PDEFormGetContent(form);
                GetCoOrdinate(content);
            else if(PDEObjectGetType((PDEObject)pdeElement) == kPDEText)
                PDETextState objPDETextState;
                PDEText aotextObject;
                memset(&objPDETextState, 0,sizeof(PDETextState));
                aotextObject = (PDEText)pdeElement;
                PDETextGetTextState(aotextObject,kPDETextRun,0,&objPDETextState,sizeof (PDETextState));
                if(objPDETextState.renderMode == kPDETextInvisible)
                    AVAlertNote("Invisible");
                else
                    PDEElementGetBBox (pdeElement, &bBox);
                    os.str("");
                    os << ASFixedRoundToInt32 (bBox.top) <<":" << ASFixedRoundToInt32 (bBox.bottom) << ":" << ASFixedRoundToInt32 (bBox.left) << ":" << ASFixedRoundToInt32 (bBox.right);
                    AVAlertNote(os.str().c_str());
            else
                os.str("");
                os << "Type: "<< PDEObjectGetType((PDEObject)pdeElement);
               // AVAlertNote(os.str().c_str());
                // Get the bounding box of the PDEElement and fill out the
                // selection structure to highlight the image.
                PDEElementGetBBox (pdeElement, &bBox);
                os.str("");
                os << ASFixedRoundToInt32 (bBox.top) <<":" << ASFixedRoundToInt32 (bBox.bottom) << ":" << ASFixedRoundToInt32 (bBox.left) << ":" << ASFixedRoundToInt32 (bBox.right);
                //AVAlertNote(os.str().c_str());

  • How can I apply text position attributes (e.g. lower third) to more than one title at a time?

    How can I apply text position attributes (e.g. lower third) to more than one title at a time?

    jhb3243
    What version of Premiere Elements are you using and on what computer operating system is it running?
    In the case of this theoretical lower third to be applied to more than one title at a time
    a. Is there text in the lower third besides a graphic of some kind?
    b. Are all the titles to which this lower third is to be applied all together on the Timeline or scattered?
    If no text in lower third and titles all together, then, with text titles on Video 1 and lower third on Video 2, drag out the lower third to cover the length of the text titles on Video 1.
    I do not find "lower third" title files to be in the same category as certain effects where the Copy and "Paste Attributes" or "Paste Effects and Adjustments" lend themselves so well.
    Let us see what others have to say about all this. I will continue to experiment with what you seek and how you would prefer to get there. I am not optimistic but I will try.
    Thanks.
    ATR

  • Getting the absolute text position from a DOM tree

    Does anybody knows how to get the absolute text position of a node inside the DOM tree? Is there any DOM implementation that keep track of the absolute text position of each Node element or I need to overload somo methods by hand?
    Regards,
    Daniel Oliveira

    The position() function in XSLT returns the order of the element.
    For an xml document with elements:
    <a>
    <b></b>
    <b></b>
    </a>
    <xsl:apply-templates select="b"/>
    <xsl:template match="b">
    Element b:
    <xsl:value-of select="position()"/>
    </xsl:template>

  • SRM - Problem with a SRM Order with text position

    Hello,
    I produced an order requisition from SRM. (Document Type EC / Field Sel.Key NBB) Unfortunately I cannot change the category of commodities during this order requisition over the transaction ME52N. This must be however possible. The appropriate Field Sel.Key NBB is correctly adjusted.
    The problem apparently lies in SRM. With normal SRM orders in the R/3 an order is put on. The category of commodities may not be changed then no more.
    With SRM orders with text positions a order requisition is to be put on in the R/3. Functions also. The category of commodities is not also here alterable only unfortunately. That must function however.
    My question: How can one change the data of the order requisition with text orders over SRM?
    Regards
    J.V.

    hi J.v
    you can make new request rather than changing the purchase request since material group in important data.
    why you want to edit the PR and again trying to edit the data in sc created from pr.
    I recommend you to create a new PR for your request.
    since
    eprofile offered sap ecc according to your material grp / purchase group combination inthe eban table (eprofile field).
    but why you are trying to edit the same pr in the backend method(it is no.2 activity in sap - not supposed to do right)
    if you dont want that request cancel the sc (complete it).
    hope now you understood.
    br
    muthu

  • Text positioning not correct while typing in Flex Mobile Text Area

    When I try to write text in Flex mobile TextArea, the text positioning is not correct. What might be the issue? Do I need to specify some Skin Class for it?

    Could be that the font doesn't have Hindi chars support and the text you paste is HTML chars.
    You could try to embed a font you know has the appropriate chars and use that for global and Applications CSS classes.

  • Compulsory quantity in text position of BOM

    Hi gurus,
    when I create a production order (CO01) and I add a text position in BOM (type T) the system requires an obligatory quantity. It's not logical  that a text position requires a quantity. Is it possible to make the text position not obligatory?
    Thank you.

    Its very typical scenario, looks stupid to ask quantity even when we mention the Item catagory as T, but there must be something behind this which our mand cant find out, we are unable to get that kind of scenario.
    by the way if you want to remove this files do as follows.
    Go to tranaxcation code. SE80>enter Function group CMOD> double click screen no 150>click on layout> screen painter will come. then click on filed required quantity.  the filed is "required" entry.
    change that to optional.
    It will solve your issue.  for this you need the access key, since its a change in standar SAP.
    Regards,
    Pravin Mukkawar
    TCS Gandhinagar
    SAP-PP-APO consultnat.

  • Horizontal text positioning of DrawString method

    I am trying to reproduce the below XPS XAML using the GDI+:
    <FixedPage xmlns="http://schemas.microsoft.com/xps/2005/06" xmlns:x="http://schemas.microsoft.com/xps/2005/06/resourcedictionary-key"
    xml:lang="und" Width="816" Height="1056">
    <Path Fill="#FFFFFFFF" Data="M0,0L816,0 816,1056 0,1056Z" />
    <Canvas Clip="M0,0L816,0 816,1056 0,1056Z">
    <Path Fill="#FFFFFFFF" Data="M0,0L816,0 816,1056 0,1056Z" />
    <Path Fill="#FF008000" Data="M0,0L816,0 816,1056 0,1056Z" />
    <Canvas RenderTransform="1,0,0,1,10,10">
    <Path Fill="#FFFFFF00" Data="M0,0L796,0 796,120 0,120Z" />
    <Canvas Clip="M0,0L796,0 796,120 0,120Z">
    <Glyphs OriginX="0" OriginY="87.5866666666667" FontRenderingEmSize="96" FontUri="/Resources/1057478c-ad6c-46da-af29-3e00c349c111.ODTTF" UnicodeString="Rutger
    Koperdraad" Fill="#FF000000" xml:lang="en-us" />
    </Canvas>
    </Canvas>
    </Canvas>
    </FixedPage>
    I manage to get the rectangles and the vertical text position correctly printed to the XPS document writer using the code below:
    Private Sub OnPrintPageEx(sender
    As Object, e
    As PrintPageEventArgs)
    If m_intPageNumber < m_objPaginator.PageCount
    Then
    Using objGraphics
    As System.Drawing.Graphics = e.Graphics
    ' Correction factor between WPF and printer units
    Dim f As
    Single = 100 / 96
    ' Set the graphics quality
    objGraphics.SmoothingMode = Drawing.Drawing2D.SmoothingMode.None
    objGraphics.InterpolationMode = Drawing.Drawing2D.InterpolationMode.NearestNeighbor
    ' Draw the green background
    Dim stcRect1 As
    New Drawing.RectangleF(0, 0, 816 * f, 1056 * f)
    Call objGraphics.FillRectangle(Drawing.Brushes.DarkGreen, stcRect1)
    ' Draw the yellow rectangle
    Dim stcRect2 As
    New Drawing.RectangleF(0, 0, 796 * f, 120 * f)
    Call objGraphics.TranslateTransform(10 * f, 10 * f)
    Call objGraphics.FillRectangle(Drawing.Brushes.Yellow, stcRect2)
    ' Draw the text
    Dim objFont As
    New Drawing.Font("Times New Roman", 72)
    Dim intEmHeight As
    Integer = objFont.FontFamily.GetEmHeight(objFont.Style)
    Dim intCellAscent
    As Integer = objFont.FontFamily.GetCellAscent(objFont.Style)
    Dim sngOffset As
    Single = 87.58667F - 96.0F / intEmHeight * intCellAscent
    Dim stcRect3 As
    New Drawing.RectangleF(0, sngOffset * f, 796 * f, 120 * f)
    Call stcRect3.Inflate(100 / 96, 100 / 96)
    Call objGraphics.DrawString("Rutger Koperdraad", objFont, Drawing.Brushes.Black, stcRect3)
    End Using
    m_intPageNumber += 1
    e.HasMorePages = (m_intPageNumber < m_objPaginator.PageCount)
    End If
    End Sub
    However, the horizontal text positioning is still different. The first letter starts too far to the right and the overall text is wider. How can I reproduce the XAML correctly in the GDI+?
    To give some background: I have a WPF application that can print using WPF/XPS technology. Since this print path gives quality problems on many legacy printer driver (bad image resolution due to a bug in the XPS to GDI+ conversion), I am building an
    alternative print engine based on the GDI+. So effectively, I need to convert my WPF graphics to the GDI+.
    Rutger Koperdraad.

    OK, I found the answer myself. By adding the string format as below, I get the correct result.
    ' Draw the text
    Dim objFont As
    New Drawing.Font("Times New Roman", 72)
    Dim intEmHeight As
    Integer = objFont.FontFamily.GetEmHeight(objFont.Style)
    Dim intCellAscent
    As Integer = objFont.FontFamily.GetCellAscent(objFont.Style)
    Dim sngOffset As
    Single = 87.58667F - 96.0F / intEmHeight * intCellAscent
    Dim stcRect3 As
    New Drawing.RectangleF(0, sngOffset * f, 796 * f, 120 * f)
    Dim objFormat As
    New Drawing.StringFormat(Drawing.StringFormat.GenericTypographic)
    Call objGraphics.DrawString("Rutger Koperdraad", objFont, Drawing.Brushes.Black, stcRect3, objFormat)
    Rutger Koperdraad.
    Thank you for sharing your solutions and experience here. It will be very beneficial for other community members who have similar questions.
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • JButton text position without an icon

    Hi,
    I'm trying to set the text on my JButtons to be in the top left corner. I've read many of the topics on JButton text position, but they all assume you have an icon with your text. I want to be able to do it without icons (as my buttons don't need them). I tried using the setHorizontalTextPosition and setVerticalTextPosition methods, but the text is still in the same spot.
    Does anyone have any ideas?
    Message was edited by:
    raardvark

    Hi,
    I'm trying to set the text on my JButtons to be in
    the top left corner. I've read many of the topics on
    JButton text position, but they all assume you have
    an icon with your text. I want to be able to do it
    without icons (as my buttons don't need them). I
    tried using the setHorizontalTextPosition and
    setVerticalTextPosition methods, but the text is
    still in the same spot.
    Does anyone have any ideas?
    Message was edited by:
    raardvarkPut a new border on the button that has some space on the bottom and right. Or add insets with the new border.

  • Skinning TextInput (and others) changes text position

    Hi there,
    I've been working on updating the visuals of our application and one path I took was skinning components. There's a designer in our team that works well with Photoshop and Flash (but not with Flex or programming at all), so I sent him the link of Narciso Jamarillo's article on creating skins for Flex using Adobe Creative Suit.
    Although we had few troubles working over the default template for HaloSkin at first, we kinda figured out most of them. But now there's one problem I couldn't find a solution yet. Whenever I apply the skins he made, the components that show text like TextInput and ComboBox start showing text in the wrong position, a little above the center and closer to the borders (sometimes it gives the impression it cuts out characters when I align the text at right).
    Here's a picture:
    Skinned on the left, not skinned on the right.
    So I'd like to know what exactly has influences over text position when I create a skin in flash, or any hint on what is causing this behavior.
    Thanks in advance.
    With regards,
    David

    I asked the designer to check in Flash and all grid lines are in proportional distance (4 pixels from edge). I also asked him to create a new skin from template, without any changes, and it displayed the same behavior, so I don't think it's a scale 9 slice configuration problem.
    Could you elaborate what kind of "minor tweaking" I could do on Flash? I ask because we just changed the shapes and and the 9 slice scale grid, is there anything else you could setup for a skin?
    David

  • Getting the text position (inside or outside a box?)

    Hi all,
    I'm using plain Ruby to access the content of an PDF file. This by using yob's PDF Reader from GitHub.
    Now I've come a long way, but still have one question remaining! How to get the position of a text object (the box of this object)?
    I've read the PDF reference, it tells me all sorts of stuff about Text Space, Glyph space and User Space... As English is not my native language it's a lot to take in... I currently do have a CTM, a Text Matrix and a Text Render Matrix. I also have all the boxes on the page (media, trim, crop etc.)
    For a Image object, I use the CTM e and f values as x and y. This works perfectly, but when it comes to text, I seem to miss something..
    Example:
    CTM: Matrix[
      [1, 0, 0],
      [0, -1, 0],
      [-0.0, 640.346, 1]
    Text matrix => Matrix[
      [10.0, 0.0, 0],
      [0.0, 10.0, 0],
      [2062769.1732, 42.6732, 1]
    ] == Needed to convert from text space to User/device space!
    Trm: Matrix[
       [1000.0, 0.0, 0.0],
       [0.0, -10.0, 0.0],
       [2062769.1732, 597.6728, 1.0]
    I can count lines, and calc a displacement by multipling this number by the Font size (12pt per example) but how do I get the the box of te text_object? If I've the box, I can make sure it fits in a box or not....
    Please help with anything I might be doing wrong, or even better if you can help me find the text position!

    So if I understand correctly:
    the CTM x and y are the starting point of my textbox (lower left corner)
    What does the text matrix do then?
    Example 2:
    CTM: Matrix[
    [1, 0, 0],
    [0, -1, 0],
    [-0.0, 640.346, 1]
    The last of each col (0,0,1) is ignored, I know :-)
    text matrix:
    Matrix text: Matrix[
    [24, 0, 0],
    [0, 24, 0],
    [50.7401, 572.1733, 1]
    So my x for the lower left here is 50.7401 and my y is 572.1733, right?
    And then we need to move the x position the number of char widths in a text, right?
    And when we move the cursor to the next line, we must use the text line matrix?

  • Problem with text positioning on webpages

    Hello,
    I have difficulties tu put text exactly the same place on the different pages of my website.
    Could someone have a look and help me?
    www.transgenic-rabbit-models.com
    It concerns the "address" text box (botom left of each page).
    Once on IE or firefox, only 2 pages are OK ("Home" and "TRM toolbox" K)
    The text box on the two other pages "Rabbits as models" and "R&D" is not correctly positionned.
    However, the properties of the text box under DW indicates they are all the same on every web page.
    I do not understand where is problem.
    I am not expert of DW...
    I would appreciate if someone could help!!!
    Thanks for your kind help.
    Regards,
    Alexandre

    You have bigger problems than you realize.   On this page - the one after the Splash intro page,
    http://www.transgenic-rabbit-models.com/Home.html
    As seen in Firefox with increased text.  See screenshot.
    Notice how your text boxes are colliding into other text boxes?  This happens when web designers paint themselves into a corner with a rigid layout.  Web pages must be flexible for all screen and text sizes.
    You are using APDivs as a primary layout method which is a bad choice.  And here is why.
    http://apptools.com/examples/pagelayout101.php
    Suggested Tutorials -
    From  Tables to CSS Web Design Part 1 -
    http://www.adobe.com/devnet/dreamweaver/articles/table_to_css_pt1.html
    From   Tables to CSS Web Design Part 2 -
    http://www.adobe.com/devnet/dreamweaver/articles/table_to_css_pt2.html
    Nancy O.
    Alt-Web Design & Publishing
    Web | Graphics | Print | Media  Specialists
    www.alt-web.com/
    www.twitter.com/altweb
    www.alt-web.blogspot.com

  • Subtitle text position off when in full screen

    I'm adding captioning/subtitles to my video (FLVPlaybackCaptioning) using dfxp.xml files. Everything works great when the video plays at it's initial resolution (640 x 360). The positioning of the captions is perfect. But I've included a Full Screen button and when the video goes full screen, the captions appear but their position is off. They are higher on the screen and they actually move upward 1 or 2 lines after they initially appear. I cannot seem to control this and am not sure why it only happens in full screen mode. In the component inspector I have set autoLayout to true and to false and it does not effect the captions one way or another. I cannot seem to find any support for this. Any help greatly appreciated.

    I've worked around this by placing the captions in a Text area below the movie. It works fine. But when I go full screen the captions remain the same size since I have had to turn off AutoLayout to get them to display in the Text Area. Anyone know how I can resize the captions automatically when the user clicks Full Screen?

  • How to get the PDF Text position, font, size, align...?

    Hi~!
    I can extract all the text from the PDF file, but just plain text.
    I need their format, position, font, size, align.
    I am using C#, IAC, and read the SDK carefully.
    How to get them?
    Thanks for every hint on how to achieve this!
    Jason Wang

    "Often this is a rectangle, sometimes not (e.g. for italic text the box
    may be slanted too)."
    Sometimes it lines up with the horizontal axis, sometimes not.
    Aandi Inston
    =====================================================
    "Remember, in PDF, the origin is BOTTOM LEFT... "
    Leonard Rosenthol
    =====================================================
    Thank you, Aandi, Leonard, Thanks a lot
    Jason Wang

  • Printing in java - text positioning

    Hi there, I need some pointers in the right direction please.
    I need to print a page out to fill in a pre-printed sheet. The data to go onto the sheet is purely numbers, but the pre-printed sheet is not in a table format (the boxes where the data goes are in seemingly random positions.)
    I am currently completing the task by laying out a panel in the way I want it and using the printComponent method, but this obviously isnt the best way to do it as all I need to print out is text.
    How is the best way to go about this? Is it possible to define the position of each line of text?
    Cheers. :)

    Well, getting the text from your JTextField should be rather easy: myJTextField.getText().
    To print it, you'll have to create an Graphics object and draw the text using the drawString method on a Graphics objects: myGraphics.drawString(myText, x, y). You will need to set the right font on the graphics before that (using the setFont() method).
    You can then use this Graphics object to print.
    See the java tutorial on printing for more info about printing: http://java.sun.com/docs/books/tutorial/2d/printing/overview.html

Maybe you are looking for

  • Plz help me...to display in  matrix  form

    Hi sir.. i want to get this report in matrix form...plz i don't have any idea about matrix form... Right now iam getting like Below format:: emp_name cat_name     type_name      theme_name                levels_skilllevel rubin      FE MODELLING SKIL

  • Change Partners for item category - TAB

    Hi All, Why it is not possible to have different ship-to-party at item level for TAB orders. For item category TAB, the partner functions is maintained as "T" which is "No item Partner". Can you help me understand why SAP has maintained like this. Pl

  • Suggest some books

    Hi Experts As i am a functional consultant (SD) module, i need to learn ESOA, As a functional consultant i need to learn Business process management(BPM), for that i need some inputs, for that please suggest some sites or if you have any documentatio

  • Problem reinstalling DW8

    Hi, I have reinstalled Dreamweaver 8 after have a trial of CS3 and although everything installs ok when i click on the icon to launch, nothing happens. i have deleted CS3 off my system but still nothing - has anyone else encountered this?

  • To see whole orders of the month

    I want to see all the sales orders/deliveries/ invoices...in this month...how???how should i do it????