I have a tableview with dynamic data from a parsed xml file. I have set a default font size, and for most entries, it works okay. However, some have an entry that seems to be cut off.. and Apple simple adds "..." to the end.
Is there a way I can implement something like a slowly scrolling banner to accommodate this? And if not, is there a way I can make the text fit if it exceeds the size without making a global change to all entries?
I think for the slowly scrolling banner you would have to implement that yourself by animating your views.
If you don't expect your text to exceed the size by that much you could try using minimumScaleFactor in ios6:
[label setMinimumScaleFactor:.75f];
or minimumFontSizeSize for < ios6.
These essentially shrink the text to fit the frame.
p.s. you can configure these in interface builder
Related
My use-case is like this:
The user defined some tags (text like "#asdf", "#qwerty", "#let_me_think_about_it" and "#decide later"). I want to display these in a box without scrolling (and don't know, how many tags the user created until I display the box).
The box itself should not be scrollable at all but be shown in a UITableViewCell (which is being scrolled). So it must compute the proposed height and respond to Autolayout mechanisms. If a (ARM) Mac user resizes the window to be smaller than before (or an iOS user rotates the device), the box should increase/decrease its height, as necessary (within the limits of Autolayout, since I know of some issues). Each of the tags should be (de)selectable at the same time (UILabel with UITapGestureRegognizer attachted?) and be able to displayed 'selected' (via a background view).
So, the box should primary try to align all content horizontal. If There's not enough horizontal space, do a "line break" and continue on the next "line".
My current solution is a UIScrollView that the user can scroll horizontal and tap any of the (UILabel) views. The displayed views itself are being loaded from a NIB file, like a UITableView does. The issue here is that not any of the selected tags might be visible at the first glance.
If there was no Autolayout, I'd exactly know what to do. But since there it is, I want to use Autolayout in my NIB files and wonder what you would do?
(How do you compute the required width of such a view and decide when a line break is to be done (and how?))
I think I need a simple hint. But if it needs code to explain, ObjC and Swift is both acceptable. :-)
So, the box should primary try to align all content horizontal. If There's not enough horizontal space, do a "line break" and continue on the next "line".
This sounds like a job for UICollectionView with UICollectionViewFlowLayout. You can disable scrolling, and the layout object will tell you the size of the content so that you can adjust the size of the box.
(How do you compute the required width of such a view and decide when a line break is to be done (and how?))
If you're doing it yourself, you add up the widths of all the items on the first line, and if it's larger than the available space, you move the item that extends past the limit and any subsequent items to the next line. Repeat as needed. But that's exactly what a flow layout does for a collection view, so there's no need to roll your own.
I'm using a Hindi font in collection view cell, there are almost 15 cells loaded into collection view
on scroll it lags, when I use the English language it scrolls smooth, But when I change the language to Hindi it starts to lag on scroll
Is there any way to solve this issue? any font caching option for font?
Is there any way to improve this using CoreText rendering?
I would recommend reading this article. It has a comprehensive set of scrolling optimisation practices for UITableViews and UICollectionViews
UPD
In your case I would look into TextKit documentation:
Text views, created from the UITextView class, are meant to display large amounts of text. Underlying UITextView is a powerful layout engine called Text Kit. If you need to customize the layout process or you need to intervene in that behavior, you can use Text Kit.
Hope this helps.
Finally, I found the issue causing scroll lag:
The lag came because UITextView's scroll was disabled and on each scroll it had to calculate the height with rendering font.
I tried with fixed height for UITextView and scroll was enabled for the same the lag disappeared
I have a large text file and I need to show it continuously, like one can do in textview. However, the rendering of the text takes a lot of time in UILable/UITextView. I have tried working with TextKit to only render the portion of the text visible on screen but was unsuccessful. TextContainer's height need to be set depending on the content height for it to work and that is no better than using UITextView or UILabel.
Is there a way to only render the portion of the text that is visible on screen without using paging. Please share your thoughts on if that is achievable with high performance.
thanks
I've got a WatchKit app that consists of a label and a couple of buttons. The label's contents might be long enough to cause scrolling, but I want the buttons to stay onscreen. Is it possible to have the label content scroll instead of the whole screen?
I've tried embedding the label in a WKInterfaceGroup, but the height of the label gets constrained to the height of the group.
I also tried to find a way to do this, but I couldn't find anything. Based on the simple flow layout for a Watch App UI I am pretty sure this can't be done.
(I am going to guess I was trying to do the same/similar UI as you ;)
I am having a usability issue where in an app screen, there may be too much text and I have nowhere to put that text.
I am attaching a screen shot of my screen. You see how the text on top has more text, but there is no room to put that text. So the text just ends in ....
What is the common way people handle this kind of a situation?
Thanks!
Redesign your UI so you have more room for that text. Maybe your content will need to scroll. You will need to change that label so that the max number of lines is greater (or 0 for unlimited), and make the frame larger to accomodate more lines. You can also reduce the font size a little to decrease how much extra space you'll need to give it.
If you really wanted to, you could use a UITextView for that text, which allows the text to scroll easily (it's a UIScrollView subclass). Then you could just scroll that text, though it wouldn't be very good UI and you would still want it to be more than one line, because scrolling when only one line is visible at a time would make it hard to read.