0

Background
I am developing a kind of UI in which i have to display
some text and then button and then some text
(I also need to handle click event).

What I tried
- I know that I can insert button into UITextView but facing trouble in getting perfect UI as the frame and of button and place from where text will start are can not manage using code.
- I search on net and found that I can use UIView as main container and add UILable for text and add UIButton where i need button.

Question
Is any one of you have develop this kind of UI ?
If YES which will be the batter way to implement that thing.

kye
  • 2,166
  • 3
  • 27
  • 41
Jageen
  • 6,345
  • 2
  • 37
  • 56
  • I'm not sure but i think you can do it with `NSMutableAttributedString `. http://stackoverflow.com/questions/20930462/ios-7-textkit-how-to-insert-images-inline-with-text – MRustamzade Sep 27 '16 at 01:29
  • @MehemmedRustemzade thanks for reply, But problem with it is i could not get click event and all stuff, I guess If you know the way of it. let me know. – Jageen Sep 27 '16 at 02:47
  • You want to make UI where there is some text then button and then some text. Do you want the text to be in continuation after the button as the user types.?like some actionable tags in between. Can you post the PNGs to be more clear? Also if the position of the button will be fixed or will it move according to the amount of text. etc. Please add detailed requirement. – Abhishek Arora Sep 27 '16 at 03:11
  • I can think that, you can do it with autolayout. See this article, if it can help you,https://www.raywenderlich.com/129059/self-sizing-table-view-cells, There is a very little coding you have to do. – Arpit B Parekh Sep 27 '16 at 07:32

3 Answers3

0

As @someone told, you can use combination of UILabel and UIButton.

Like calculate text size by using boundingRectWithSize: and then create and add UILabel according to that size and where UILabel completes start to draw UIButton and add it….and so on….

You have to do this UI programmatically, that is a big challenge. You want something like : (You can handle button click)

Handle Button Click between text

VRAwesome
  • 4,721
  • 5
  • 27
  • 52
0

I was worked on that type of UI.The best Approach for this kind of UI is use UIWebView where you can insert text and also Link buttons and also you can store info on this links button.I think UIWebView is best Approach for this kind of UI.I hope this will help you.

Sumit Jangra
  • 651
  • 5
  • 16
  • I did not think on that way, Thanks for direction, side note : is there any problem like say, scrolling or UI cut, in boundary, And I have to write HTML code for that also right ? – Jageen Sep 28 '16 at 06:06
  • WKWebView will be the correct approach, I just code and it flexible solution , And as the text would be dynamic and might contain big set of controls, so generate all control my self let WKWebView handel the X and Y frame of them – Jageen Sep 28 '16 at 07:45
0

AutoLayout


Label - number of lines - 0

Add constraint

Button

Add constraint

Label - number of lines - 0


This way you can do.

Arpit B Parekh
  • 1,932
  • 5
  • 36
  • 57