I have a UITextField with the adjustsFontSizeToFitWidth property set to YES. I want to get ahold of the current (adjusted) font size. Is that possible?
If not, getting ahold of the actual width of the text (in the adjusted size) would be almost as good.
In the adjusted size, the width of the text would be the same as the width of the text field.
I don't think it's possible, but it should not be too difficult to write your own class.
Here's a small snippet/extension I wrote down to handle this.
http://swiftstub.com/134886004/
Related
I am kind off struck in implementation of indexed UITableView. The content display size of tableview in my application is of dimensions 320X250. I am successfully able to display the indexes in tableview as display area is small so half of indexes are displayed by default as "dot symbol".
Any suggestion regarding this would be really helpful.
Cheers!!!
For that,
You have to take UILabel inside the "cellForRowAtIndexPath" method.
And assign the label x, y position and width & height.
So, it will be display properly.
Let me know if you want source code for that.
That is the default behavior of iOS. It automatically truncates the indexes when they are too many to display.
I have iOS 4.3 installed on my iPad. I'm noticing that my text in my UILabels is not resizing. In other words, I'm adding letters, but it's just truncating. Same settings work find on iPhone also running 4.3. I'm perplexed. I've made certain that "Adjust to fit" is checked on the label properties. I've even set it in the code with .adjustsFontSizeToFitWidth and even tried calling sizeToFit.
None of these let the text resize.
Does anyone else have this problem?
Any ideas?
My next solution is going to use this: Check if label is truncated to try and manually resize the label text.
I finally figured it out. I'm using OHAttributedLabel. I had intended to do some things with color in my labels and have not yet gotten around to it. It finally dawned on me that was the only difference from previous iPad versions and from the iPhone version (I never even thought to look at the class). Turns out this OHAttributedLabel class does not support resizing yet.
Sorry for wasting everyones time. Maybe someone else will someday find this useful.
Try using CGSize eLabelSize = [yourLabel.text sizeWithFont:yourLabel.font]; to get the size of the label and then you can simply modify the yourLabel.frame.size property with eLabelSize.
This worked for me in case of iPhone.
Hope this works for you if yes do communicate..... :)
Maybe it only appears as if the label is truncating text because the label frame runs out of the bounds of its parent view, which clips to its bounds? Verify the frame of the label and the autoresizing mask.
Also, the minimumFontSize property is set low enough?
I have several UIButtons, I'm trying to bulk change the font for all of them in InterfaceBuilder, but when I change the font, they auto-resize to the original image dimensions instead of what I had them set to, screwing up the layout. I would like to avoid having to resize and move everything around again any time I change the font. I could just set the font in a loop in code, but it seems redundant.
Is there a setting to stop this from happening?
This issue doesn't seem to occur in Xcode 4.0 or above.
Should anyone still be using a lesser version of Xcode I would suggest updating.
im searching for a solution of the following problem:
i got a "larger" XHTML string that i want to display in an area that is scrollable.
I already used TTStyledTextLabel for a small text-caption and it works pretty well.
But now i want display it more like a UITextView that scrolls or a UIScrollView with my TTStyled Content in it. i think TTStyledTextLabel isnt the right thing to view such a large (with large i mean about 900px height) content.
i need a TTStyledTextView, or something like that. Does something exist? How to work with it. My Content has a variable length so i cannot setup a UIScrollView with a TTStyledTextLabel in it.
Any hints for me ?
Thanks!
You can determine the height needed to display the whole XHTML string by doing this:
htmlLabel.text = [TTStyledText textFromXHTML:htmlText];
[htmlLabel sizeToFit];
CGFloat height=htmlLabel.height;
I do this to create dynamic table cells that include these labels. You can use this height to set the contentSize of a parent scrollview.
You might however run into problems if your view is higher than 1024pixels on iPhone OS 2.x:
Note: Prior to iPhone OS 3.0, UIView instances may have a maximum height and width of 1024 x 1024. In iPhone OS 3.0 and later, views are no longer restricted to this maximum size but are still limited by the amount of memory they consume. Therefore, it is in your best interests to keep view sizes as small as possible. Regardless of which version of iPhone OS is running, you should consider using a CATiledLayer object if you need to create views larger than 1024 x 1024 in size.
Is there any way to customize the datepicker used in iphone?
I want to change height & width of it.
Can we change the background color, font color of it?
Please help if anybody has done before.
Thanks in advance ...
The size cannot be changed. There are other questions concerning this and several ways to fake it, moving it partially offscreen or putting other views in front partially obscuring portions or adding background images to make it look larger. The best approach is to use it as-is or write a custom picker.
Or you can create your own picker ;)
I created this component that allows you to do this really easily: http://dev.doukasd.com/2011/04/infinite-scrolling-dial-control-for-ios/