Latest on twitter from msanchezmora 
  • loading...

Resizing UITextView based on its content

Posted: October 8th, 2010 | Author: | Filed under: Uncategorized | No Comments »

Just a quick piece of code illustrating how to resize height and width of a UITextView based on its content.

It’s important to add approximately 30 pixels to the final height and 15 pixels to the final width because sizeWithFont function does not take into account the small horizontal and vertical margins within a UITextView.

Enjoy!

  1. CGSize sizeForTextBox(NSString * text, NSString *fontName, CGFloat fontSize, CGFloat max_width, CGFloat max_height)
  2. {
  3. UIFont *helvFont = [UIFont fontWithName:fontName size:fontSize];
  4. CGSize maxTextBoxSize = CGSizeMake(max_width,max_height);
  5. CGSize textBoxSize = [text sizeWithFont:helvFont
  6. constrainedToSize:maxTextBoxSize
  7. lineBreakMode:UILineBreakModeWordWrap ];
  8. textBoxSize.height = textBoxSize.height+30;
  9. textBoxSize.width = textBoxSize.width+15;
  10. return textBoxSize;
  11. }

Post to Twitter


SQLCipher and SQLiteManager: Are they compatible?

Posted: October 5th, 2010 | Author: | Filed under: Uncategorized | No Comments »

After a long break here I am again sharing my daily discoveries regarding software and overall iPhone programming. This time I am encrypting SQLite databases using SQLCipher and OpenSSL libraries into my iPhone iOS4 project.

Using an encrypted DB with SQLiteManager does not work with SQLCipher, I haven´t found which encryption algorithm is used by SQLiteManager therefore I haven´t been able to decrypt it using SQLCipher from my iPhone app.

My recommendation is: compile and run SQLCipher, and then encrypt the DB from the command line. This method works flawless, less fancy than using a graphical app but successful!
Next a link with detailed instructions:
how to encrypt a plaintext SQLite DB

Post to Twitter