Draw beautiful diagram effortlessly on ipad. Click here to know more..

Saturday, March 23, 2013

Variable size text view in iOS (iPad and iPhone)

Based on specific need, you may want a variable size text view on iOS as

  • Fixed width. Vary height based on length of text
  • Vary both width and height, based on length of text. You will increase height if new line is added otherwise increase width.
These two kinds of text views are used in "Lekh Diagram" app. This is a diagramming app. You can add text on a shape, or free floating text. If text is added on a shape, then width of text is constrained to the width of shape. The free floating text has variable width and height.

Lets see how to do in code:
Add to text boxes, one for fixed width and other for variable width and height.

In ViewController.h

#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *textView1;
@property (weak, nonatomic) IBOutlet UITextView *textView2;
@end

In ViewController.m

#import "ViewController.h"

@implementation ViewController
- (void)viewDidLoad
{
    [super viewDidLoad];
    self.textView1.delegate = self;
    self.textView2.delegate = self;
}
- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
}
-(BOOL)shouldAutorotate
{
    return NO;
}
- (void)textViewDidChange:(UITextView *)textView
{
    // textView2 has variable width and variable height
    if (textView == self.textView2) {
        // max widht and height: some random big value
        float maxWidth = 40000;
        float maxHeight = 40000;
        
        CGSize sz = [textView.text sizeWithFont:textView.font constrainedToSize:CGSizeMake(maxWidth, maxHeight)];
        
        // There is some margin around text view. we need to consider margin,
        // otherwise there will text wrapping without new line.
        sz.width += 32;
        sz.height += 16;
        
        CGRect frame = textView.frame;
        frame.size = sz;
        textView.frame = frame;
    }
    else {
        // textView1 has fixed width and variable height
        CGRect frame = textView.frame;
        frame.size.width = textView.contentSize.width;
        frame.size.height = textView.contentSize.height;
        textView.frame = frame;
    }
}
@end


In code above, textView2 has variable width and height and textView1 has fixed width.
Download code from here

The code above is based on code used in "Lekh Diagram", a sketch recognition diagramming app for iPad and iPhone.
Get "Lekh Diagram" from app store: https://itunes.apple.com/us/app/lekh-diagram/id576124115?mt=8


169 comments:

  1. I agree with your post. Android software development kit makes the application development process lot simpler and effective. You can create best performing android application with ease. Android Training Institutes in Chennai

    ReplyDelete
  2. Please count the heads to come disagreeing over a noble sense of dressing either to them or to their darling gizmos to wear. If yes, it shapes them unlikely to please all socially. teleprompter

    ReplyDelete
  3. This blog had a to a great degree solid effect on me.
    visit our website

    ReplyDelete
  4. The new hello tech Austin Convention Center proposed disposal of printed material requests bringing about 200 percent ROI for the tech monster.click for more info

    ReplyDelete
  5. This comment has been removed by the author.

    ReplyDelete
  6. Pretty post, Thanks for sharing an innovative idea, It is useful information for beginners.
    Learn Android course.

    ReplyDelete
  7. Such a beautiful content, this writer is very smart selection of the page.
    i proud of that writer, thank you.
    2stage and single stage snow blower

    ReplyDelete
  8. I was barely amazed at how you had written this content. Please keep posting.
    free java training in chennai
    Core Java Training

    ReplyDelete
  9. Very true and inspiring article. I strongly believe all your points. I also learnt a lot from your post. Cheers and thank you for the clear path.
    hadoop big data training in chennai
    best institute for big data in chennai

    ReplyDelete
  10. Superb information, as always. After reading this one I really got refreshing and fantastic feeling! This is also a great and encouraging post.
    best dot net training
    dot net course

    ReplyDelete
  11. I am always searching online for articles that can help. There is obviously a lot to know about this. I think you made some good points.

    cloud computing training chennai
    cloud computing training centers in chennai

    ReplyDelete
  12. This is the best explanation I have seen so far on the web. I was looking for a simple yet informative about this topic finally your site helped me a lot.

    Software testing training
    Software training

    ReplyDelete
  13. Thanks for blogging about Software Testing, I hope you will post more regarding software testing, keep blogging...
    Regards,
    be projects in chennai | msc projects in chennai

    ReplyDelete
  14. Easily peruses text from messages, internet browsers, PDFs and regular projects, for example, Outlook, Pages, Preview, and Text Edit.read this to me

    ReplyDelete

  15. This was an nice and amazing and the given contents were very useful and the precision has given here is good.
    Java Training in Chennai

    ReplyDelete
  16. This was an nice and amazing and the given contents were very useful and the precision has given here is good.


    Bigdata AnalyticsTraining in Bangalore

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. You finished a couple fine focuses there. I did an inquiry on the subject and discovered about all persons will oblige with your online journal. Tax Enquiry Accounts

    ReplyDelete
  19. Much obliged to you again for all the information you distribute,Good post. I was exceptionally keen on the article, it's entirely rousing I ought to concede. I like going to you site since I generally run over fascinating articles like this one.Great Job, I incredibly acknowledge that.Do Keep sharing! Respects, HMRC Tax Investigation Accountants

    ReplyDelete
  20. You have a decent point here!I thoroughly concur with what you have said!!Thanks for sharing your views...hope more individuals will read this article!!! Tax Enquiry

    ReplyDelete
  21. On the off chance that more individuals that compose articles truly fretted about composing incredible substance like you, more perusers would be occupied with their works. Much obliged to you for thinking about your substance. Let Campaign Tax Enquiry

    ReplyDelete
  22. When visiting blogs, i always look for a very nice content like yours .   Tax Investigation Self Employed

    ReplyDelete
  23. Thank you a lot for providing individuals with a very spectacular possibility to read critical reviews from this site.
    python training in tambaram | python training in annanagar | python training in jayanagar

    ReplyDelete
  24. Thank you for sharing such great information with us. I really appreciate everything that you’ve done here and am glad to know that you really care about the world that we live in
    advanced excel training in bangalore

    ReplyDelete
  25. I truly like you're composing style, awesome data, thankyou for posting. Let Property Campaign

    ReplyDelete
  26. I am trusting the same best exertion from you later on too. Truth be told your experimental writing abilities has roused me. Let Property Campaign Accountants

    ReplyDelete
  27. Awesome article. It is so detailed and well formatted that i enjoyed reading it as well as get some new information too.
    Java training in Chennai | Java training in Bangalore

    Java interview questions and answers | Core Java interview questions and answers

    ReplyDelete
  28. Great Article...Thanks for sharing the best information.It was so good to read and useful to improve my knowledge as updated one.

    iOS Training in Chennai
    Android Training in Chennai
    Mobile Apps Training in Chennai

    ReplyDelete
  29. Thanks for your sharing such a useful information. this was really helpful to me

    zhosters
    Guest posting sites

    ReplyDelete

  30. Thank you for taking the time to write about this much needed subject. I felt that your remarks on this technology is helpful and were especially timely.


    devops course fees in chennai | devops training in chennai with placement | devops training in chennai omr | best devops training in chennai quora | devops foundation certification chennai

    ReplyDelete
  31. Hello! This is my first visit to your blog! We are a team of volunteers and starting a new initiative in a community in the same niche. Your blog provided us useful information to work on. You have done an outstanding job.

    Best AWS Training in Chennai | Amazon Web Services Training in Chennai
    AWS Training in Bangalore | Amazon Web Services Training in Bangalore
    Amazon Web Services Training in OMR , Chennai | Best AWS Training in OMR,Chennai

    ReplyDelete
  32. Nice Information http://www.stylobe.com

    ReplyDelete
  33. I can’t imagine focusing long enough to research; much less write this kind of article. You’ve outdone yourself with this material. This is great content. Buy to Let Property Tax Advisors

    ReplyDelete
  34. This is my first time i visit here. I discovered such a large number of fascinating stuff in your web journal particularly its discourse. From the huge amounts of remarks on your articles, I figure I am not by any means the only one having all the satisfaction here! keep doing awesome Buy to Let Property Tax Advice

    ReplyDelete
  35. Wow, this is really interesting reading. I am glad I found this and got to read it. Great job on this content. I like it. seo services

    ReplyDelete
  36. This is extremely instructive substance and composed well for a change. It"s pleasant to see that a few individuals still see how to compose a quality post! domain authority blog comments

    ReplyDelete
  37. I as of late discovered numerous helpful data in your site particularly this online journal page. Among the loads of remarks on your articles. A debt of gratitude is in order for sharing. Buy to Let Tax Advisor

    ReplyDelete
  38. Pleasant web journal and totally exceptional. You can improve yet despite everything I say this perfect.Keep striving generally advantageous. Buy to Let Property Tax Advice London

    ReplyDelete
  39. It turned out to be Very useful to me and I am certain to every one of the observers here! Property Tax Accountant

    ReplyDelete
  40. That is the excellent mindset, nonetheless is just not help to make every sence whatsoever preaching about that mather. Virtually any method many thanks in addition to i had endeavor to promote your own article in to delicius nevertheless it is apparently a dilemma using your information sites can you please recheck the idea. thanks once more. Property Tax Advice

    ReplyDelete
  41. A debt of gratitude is in order for sharing the data, keep doing awesome... I truly delighted in investigating your site. great asset... Property Tax Advisors

    ReplyDelete
  42. I was taking a gander at some of your posts on this site and I imagine this site is truly informative! Keep setting up.. Tax on Buy to Let Property

    ReplyDelete
  43. This was truly a fascinating point and I kinda concur with what you have said here! Tax Investigation Accountants

    ReplyDelete
  44. This is a really decent site post. Not very numerous individuals would really, the way you simply did. I am truly inspired that there is such a great amount of data about this subject have been revealed and you"ve put forth a valiant effort, with so much class. On the off chance that needed to know more about green smoke surveys, than by all methods come in and check our stuff. Tax Investigation Advisors

    ReplyDelete
  45. This comment has been removed by the author.

    ReplyDelete
  46. Much thanks for composing such an intriguing article on this theme. This has truly made me think and I want to peruse more. Tax Investigation Self Assessment

    ReplyDelete
  47. thanks for your Draw beautiful diagram effortlessly on ipad.
    android training in chennai

    ReplyDelete
  48. Companion, this site may be fabolous, i simply like it. Tax Investigation Accountants

    ReplyDelete
  49. You may tune in to any of the stored text while driving, practicing or voyaging. In this way, the utilization of a MP3 player isn't restricted to simply tuning in to music, and you stay gainful even while driving. notevibes.com

    ReplyDelete
  50. Incredible Information sharing .. I am exceptionally glad to peruse this article .. a debt of gratitude is in order for giving us experience info.Fantastic pleasant. I welcome this post. Tax Investigation Specialists

    ReplyDelete
  51. Your site furnished us with profitable data to work with. Each and every tips of your post are magnificent. You rock for sharing. Continue blogging.. Tax Investigation Self Assessment

    ReplyDelete
  52. This is extremely fascinating substance! I have completely appreciated perusing your focuses and have arrive at the conclusion that you are right about large portions of them. You are extraordinary. Tax Investigation Self Employed

    ReplyDelete
  53. Incredible data! I as of late went over your site and have been perusing along. I thought I would leave my first remark. I don"t comprehend what to say aside from that I have. Revenue Tax Investigation

    ReplyDelete
  54. its is very very helpful for all of us and I never get bored while reading your article because

    AWS Training in Bangalore

    Best AWS Training Institute in Bangalore

    ReplyDelete
  55. I read this post two times, I like it so much, please try to keep posting & Let me introduce other material that may be good for our community.
    aws online training

    data science with python online training

    data science online training

    rpa online training

    ReplyDelete
  56. Thanks for sharing this information admin, it helps me to learn new things. Continue sharing more like this.
    Regards,
    Tableau training in Chennai | Tableau Courses Training in Chennai | Tableau training Institute in Chennai

    ReplyDelete
  57. I am all that much satisfied with the substance you have specified. I needed to thank you for this extraordinary article. Tax Investigation Self Employed

    ReplyDelete
  58. You know your activities emerge of the group. There is something extraordinary about them. It appears to me every one of them are truly splendid! Tax Investigation Accountants

    ReplyDelete
  59. I as of late ran over your online journal and have been perusing along. I thought I would leave my first remark. I don"t comprehend what to say with the exception of that I have appreciated perusing. Pleasant site, I will continue going by this online journal all the time. Tax Investigation Self Assessment

    ReplyDelete
  60. Hello, I discover perusing this article a delight. It is to a great degree supportive and fascinating and all that much anticipating perusing a greater amount of your work.. Revenue Tax Investigation

    ReplyDelete
  61. This is an awesome motivating article.I am practically satisfied with your great work.You put truly exceptionally accommodating data. Keep it up. Continue blogging. Hoping to perusing your next post. backlinks service

    ReplyDelete
  62. This is a decent post. This post gives genuinely quality data. I'm unquestionably going to investigate it. Truly extremely valuable tips are given here. Much obliged to you to such an extent. Keep up the benevolent acts. premium car service kennesaw ga

    ReplyDelete
  63. The post is composed in exceptionally a decent way and it contains numerous valuable data for me. Tax Investigation Accountants

    ReplyDelete
  64. I've been hunting down some better than average stuff on the subject and haven't had any fortunes up until this point, You just got another greatest fan!.. Tax Investigation Advisors

    ReplyDelete
  65. Amazing and fascinating article. Incredible things you've generally imparted to us. Much obliged. Simply keep making this kind out of post. Tax Investigation Self Assessment

    ReplyDelete
  66. Extremely fascinating online journal. Alot of online journals I see nowadays don't generally give anything that I'm keen on, however I'm most definately intrigued by this one. Recently felt that I would post and let you know. Tax Investigation Specialists

    ReplyDelete
  67. If you can't write application essay , that is not problem! You can order it from the best application essay writers ever. I should say that I was completely satisfied by the results!

    ReplyDelete
  68. Are you looking for an explanation of complex topics? Look for information here http://essaylab.co.uk/.

    ReplyDelete
  69. If you are looking for live train data then check at this site

    ReplyDelete
  70. Get online essay writing help Australia from the Australian expert writers. At StudentsAssignmentHelp.com, students receive the top-class University essay writing help Australia services and make the highest marks in their academics.

    ReplyDelete
  71. This comment has been removed by the author.

    ReplyDelete
  72. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. Machine Learning Final Year Projects In case you will succeed, you have to begin building machine learning projects in the near future.

    Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.


    Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

    ReplyDelete
  73. You have a great sense of writing I must say. Your post has those facts which are not accessible from anywhere else. It’s my humble request to u please keep writing such remarkable articles cursos de ti online

    ReplyDelete
  74. Myself, William Smith Associated with Livewebtutors. Which Is Known as A Renowned accounting assignment help Australia Company. I Have Been Working as A Full-Time Academic Consultant from Last Ten Years. Livewebtutors Is an Experienced and Highly Reputable All Assignment Help Provider in Australia, Specialized in Academic Writing. We Offer High-Quality Service and Supply Free Plagiarism Report for All Assignments and Best Price.

    ReplyDelete
  75. ABC Assignment Help is the only solution for students looking for quality Autodesk Revit assignment help. As our subject experts help students in achieving their desired result and success in career. Contact us now to get best and 100% authentic write-ups from top professionals.

    ReplyDelete
  76. Nice article! A very Informative concept which explained about variable size text view in IOS platform. Thanks for sharing the tips and detailed instructions on coding as it helps the beginners. Keep posting more furnished contents!

    Mobile App Development Companies in Chennai

    ReplyDelete
  77. Avoid physical connection amid of COVID-19 and meet the team of experienced assignment helpers via Assignment Help in Jordan. Students can finish their papers without any stress using Online Assignment Help even in Jordan.

    ReplyDelete
  78. https://researchpapers247.com/religion-research-paper-services/

    ReplyDelete
  79. Thank you for that valuable post. Fresher’s have struggle to learn web design and developement applications in this post guide that students and give more extended knowledge of web technology. great jobs
    Ai & Artificial Intelligence Course in Chennai
    PHP Training in Chennai
    Ethical Hacking Course in Chennai Blue Prism Training in Chennai
    UiPath Training in Chennai

    ReplyDelete
  80. The modern world forces us to be hardworking and purposeful. We have a lot of tasks to do every day, from our day-to-day responsibilities to our work. That's why I often look for people who can help me with my studies. You will not believe, but I came across with a service for writing tasks https://essaywriter.org/ They do their job very well and never fail. Therefore, I advise this service to everyone:)

    ReplyDelete
  81. The knowledge of technology you have been sharing thorough this post is very much helpful to develop new idea. here by i also want to share this,wonderful article. Very interesting to read this article.I would like to thank you for the efforts you had made for writing this awesome article.

    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    oracle online training

    hadoop training in chennai

    hadoop training in bangalore

    ReplyDelete
  82. traktor crack download Serial Key is professional and effective 4-deck DJ software to make music songs with the program that is simple. The individual should create a dream remix with a magical loop and cueing. Through FX suite you are able to add drama, music track, tension, etc. It really is DJs best and DJ that is reliable software with all styles. Traktor screen is customizable you want and browse iTunes library directly using this software so you can fit mixing style exactly what. Due to its interface that is customizable and workflow, it allows one to create unique songs and edit them with remix decks loop property. Traktor pro layout leads to the modification that is complete.There is also some control that is technical of DJ for iOS to the MAC system. Traktor Apk is a program for advantages DJs. also in terms of beginners to mix several audio tracks, loops, and examples for a production that is new to music.

    ReplyDelete
  83. As per the policy of Air France Airlines Cancellation, the request for cancellation can be made according to the fare rules. The customer may get the full refund, partial or no-refund at all. It totally depends on the flight tickets, cabin class type, elite status of travelers and the time period when the request has been made.

    ReplyDelete


  84. Saving and Travelling is my two favorite things, but find a cheap flight always gives me a headache. Finally, I got a great solution when I was flying with Lufthansa Airlines. Prompt and amazing Lufthansa Airlines Phone Number, I got amazing deals and discounts with the best facilities. I will recommend Lufthansa Airlines Phone Number to all travelers.

    ReplyDelete
  85. Higher education is a lofty endeavor with as many difficulties in its path as there are opportunities. ScholarOn provides Algebra Expert Answers for every learning need possible. Satisfied students over a decade remains our achievement in the online academic industry.

    ReplyDelete
  86. I have bookmarked your site for future reference. Good work. Most of the students come up to us for capsim homework help and always return satisfied. Our main purpose is to help you gain the best grades through your paper. We don’t have any concern with the reason behind asking for help; our main aim is delivering you the best capsim homework help. Captive simulation is named as capsim that is basically designed to teach students the different functional elements and the linking of decision and operational results. Moreover, it also develops the strong skills and commitments in the students to ensure academic and professional life success. Go ahead and reach out to us for Capsim simulation Help

    ReplyDelete
  87. TestBanksOnline is the best website to Buy Test Banks Online. Great study materials like Dynamics Of Structures 5th Edition Solution Manual are available with instant download and best discounts. Search 4000+ test banks and solution manuals online.

    ReplyDelete
  88. Bandicam Crack will help you carry out a screen capture with high compression ratio, while keeping the video quality closer to the original work, and provides performance far superior to other screen capture software that provides similar functions.

    ReplyDelete
  89. Amazing article. Your blog helped me to improve myself in many ways thanks for sharing this kind of wonderful informative blogs in live.
    DevOps Training in Chennai

    DevOps Course in Chennai


    ReplyDelete
  90. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot. Epson error code 0xf3

    ReplyDelete
  91. When checking for the kids car then have to get here

    ReplyDelete
  92. Bachelor of Commerce Semester wise Exam Routine 2021 now available online. Students Can Check 1st 2nd 3rd Year BCom Exam Timetable 2020-2021.
    Matsya University BCom Time Table 2021
    MDSU BCom Time Table 2021
    Rajasthan University BCom Timetable 2021
    RDVV BCom Exam DateSheet




    ReplyDelete
  93. when looking for the website for cheap beds here to get the best out of them

    ReplyDelete
  94. There are reliable criminal justice research writing services that are very popular for students in search of criminal justice paper writing services and criminal justice assignment writing services.

    ReplyDelete
  95. Thanks for giving me grateful information. I think this is very important to me. Your post is quite different. That's why I regularly visit your site.
    Check Also This - CTET Exam Admit Card
    UP Police Constable Recruitment
    Delhi Police Constable Admit card

    ReplyDelete
  96. Students Can Check 1st 2nd 3rd Year B.com Exam Schedule 2020-2021.
    MDSU BCom Time Table

    ReplyDelete
  97. Textile industry Software

    Generally, software applications that have 2D or 3D technology integrated into them are used in the dyeing, printing, and finishing industry. Computer Aided Application (CAD), Computer Aided Manufacturing (CAM), and Computer Integrated Manufacturing (CIM) are the three main software applications used.

    ReplyDelete
  98. Our Online Assignment Help presents a viable opportunity for the students struggling with their assignment to help them achieve excellence in their work. We render one-shot satisfaction.
    accounting assignment help

    ReplyDelete
  99. is an updated Indonesian game news portal that discusses various interesting information about News, Esports, Guides, Builds, and gamesorbit various interestingly packaged Android and PC game reviews.

    ReplyDelete
  100. We love to interact with our audience so we hope you’ll join our community by subscribing and commenting on the blog.
    driver

    ReplyDelete
  101. This is the perfect web site for anyone who wishes to find out about this
    topic. You understand so much its almost hard to argue with you (not that I
    personally will need to…HaHa). You certainly put a new spin on a topic
    which has been discussed for ages. Wonderful stuff, just wonderful!
    Hadoop Training in Bangalore
    Python Training in Bangalore
    AWS Training in Bangalore
    UI Development training in Bangalore
    Machine Learning Training in Bangalore
    Machine Learning Training with Python in Bangalore
    Data Science Using Python Training in Bangalore

    ReplyDelete
  102. A very awesome blog post. We are really grateful for your blog post. You will find a lot of approaches after visiting your post.Hi! We are water treatment company in uae Great points made up above! And list of water treatment companies in Dubai thanks… I think this is one of the most important information for me. And i am glad reading your article. But should remark on few general things…

    ReplyDelete
  103. Welcome you to the world of pleasure with a type of Models Girls Services in Lahore who make you satisfied beyond the limits, this is one of those places for each of your fantasies and it will be fulfilled through the girl of In a spectacular way, get in touch with our university students to reinforce your intimate life and come to understand where the real pleasure really lies.

    ReplyDelete
  104. Thank you for this wonderful read! I absolutely loved every bit of it. I have got you book-marked to check out new stuff on the next updates; just wanted to say, I enjoyed this post. Thanks for sharing. Also read post utme past questions and answer for wusto

    ReplyDelete
  105. This post is so interactive and informative.keep update more information…
    Tally Course in Anna Nagar
    Tally course in Chennai

    ReplyDelete
  106. This comment has been removed by the author.

    ReplyDelete
  107. This comment has been removed by the author.

    ReplyDelete