I'm loading text data from xml to my today widget label so height can't be static. Since font size is 17px I counted that there are max 30 characters in one line, and by that I tried to set height like this
int number_of_characters = [self.string length];
[label sizeToFit];
self.preferredContentSize = CGSizeMake(self.view.frame.size.width, (number_of_characters/30)*22+40);
I add +40 to height because I have static text on top of widget, and multiple by 22 since font size is 17px I assumed that there's 5px spaceing between two lines.
But this doesn't work, I can't figure why :( . Is there some other way to make widget height dynamic?