开发者

How to display some part of the string in One TextView and reaming in Other

in my application i have

IBOutlet UITextView *newsFirstPart;
IBOutlet UITextView *newsSecondPart;

IBOutlet UILabel *newsTitle;
IBOutlet UIImageView *newsImgView;

IBOutlet UIButton *sendBtn;

I am displaying some string content in my TextViews programmically .The following is a design of my ScrollView. Means here i am parsing the string content from an xml file . So the string length should vary in every case .

I want to display some part of the string content in the first TextView , means it should depend the height of the *newsFirstPart and all the remaining string in the second *newsSecondPart.

Also I want to place my UIButton 'Send' after the Second TextView programmically.

Depending the height of the Second TextView , I have to set my ScrollView content size.

How can I display some part of the string in One TextView and remaining in Other?

!------------------------------!
!---------------!--------------!
! newsTitle                    !
!------------------------------!
!               !              !
! 开发者_StackOverflow中文版              !              !
! newsFirstPart ! newsImgView  !
!               !              !
! fixed height  !              !
!---------------!--------------!
!                              !
!                              !
!        newsSecondPart        !
!                              !
!                              !
!                              !
!      Dynamic Height          !
!                              !
!-------------------------------
!                  !---------! !
!                  | SendBtn | !
!                  !---------! !
!                              !
!------------------------------!


This is hard to do using only UIKit objects since there is no public method in UIKit that allows you to know what substring of your string will fit in your first textview.

I would recommend you give a try to the CoreText framework.

have a look at the columns example

https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/CoreText_Programming/LayoutOperations/LayoutOperations.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜