I have updated my device iOS to iOS 8 and now multiline label is not working. Its displaying very weird screen shot attached.
So please can you suggest me the solution.
I already set Number of lines =0 and it was working perfect in ios 7.
Not using Autolayout and story board.
This code help you.It works fine me.Edit your code according to need
UILabel *problem = [[UILabel alloc] initWithFrame:CGRectMake(40, 100, 200, 100)];
problem.lineBreakMode=NSLineBreakByWordWrapping;
problem.text=#"Please use this code it may help you it works fine for me";
problem.numberOfLines=0;
[self.view addSubview:problem];
Strangely enough, this fix doesn't work if you don't use all of it:
Set the line break mode to word wrapping (if that's the affect you want).
Set the number of lines to 0 (I had it set to 2 and it still didn't work).
Not sure if something changed here with the introduction with iOS 8 but my previous code (just setting the number of lines to 2) was working great on iOS 7.
Anyone else face a similar issue?
Do you use a custom font?Try changing the font.
Related
I've got a few buttons with text inside. If i run the app on an iOS 10 device, it works and shows the text fine. But running the app on iOS 9 the text inside the button is like "squashed" or "compressed"(the text on version 9 is missing the top and bottom part of the text). I'm not sure why this is happening, I've tried messing around with the hugging and compression settings on the UI Builder, but this hasn't really fixed the problem.
Not sure why it works on 10 but not on 9....The image above shows what the text looks like on iOS 9 ONLY!
I'm just seeing if this is happening with anyone else? or if anyone knows how to solve this problem?
I appreciate any help given! Thanks in advance!
You have to use "adjustsFontSizeToFitWidth" property of titleLabel of your button
Example:
myButton.titleLabel.adjustsFontSizeToFitWidth = YES;
There are a few possibilities:
The height of the button during runtime could be wrong. Try setting a border to the button, run and observe the button outline to see if the height is correct.
myButton.layer.borderColor = UIColor.black.cgColor
myButton.layer.borderWidth = 1
If the height is wrong, it means the constraints could be incorrectly set up.
Another possibility might be contentEdgeInsets, titleEdgeInsets properties of the button having larger than intended top and bottom values.
In my app I use a UIPopoverController with an embedded UINaviagtionController to show a single line UITextField to enter a number. This kind of input was working up to iOS 7.1. Since iOS 8.0 the size of the UITextField is wrong. I tried out to change the AutoresizingMask, Frame, EdgesForExtendedLayout, ... but nothing is working.
As you can see in the screenshots bellow, there is a strange behaviour.
A sample project for Xamarin.iOS is available: http://www.danflash.com/files/dev/PopoverTest.zip
I have found the issue. I had to set contentViewController.EdgesForExtendedLayout = UIRectEdge.None; within the method:
public static PopoverInputController GetPopoverController(...)
It seems that Apple did some more changes to the UI regarding the layout stuff as expected.
I have a UILabel which I was able to rotate using the following code in iOS 7,
self.mylabel.text = #"Search customer";
[self.mylabel setTransform:CGAffineTransformMakeRotation(-M_PI / 2)];
with reference from this thread.
However, when I tried to use the similar code in iOS 8, I got a slightly different result, whereby my string look distorted and is separated into a few lines.
In iOS 7, it displays nicely in one line at a 90 degree rotation.
I wonder anyone face the same issue as me, and how can I solve this?
I am developing an application that target iOS6+.
I have a text view with with large attributed text. Maybe 1000 lines odd lines red color and other lines green color.
I use below code for changing the font size of the textview:
self.doaTextView.editable= YES;
self.doaTextView.font = [UIFont systemFontOfSize:self.FontSilder.value];
self.doaTextView.editable= NO;
but it takes much time. It is about 2 second on iOS 7 and about 5-10 second on iOS 6!!!
(I enable and disable editable feature, becasue if I do not do this the changes not appear in iOS 6. Please see here)
What is the problem?
Edit
I found this topic related to this problem too. Really there is not any solution for this?
I finally fixed this problem by recreating my attributedtext again and setting it as a new attributedtext to my uitextview.
If I set linebreakmode to truncation tail in the TTTAttributedLabel Example App "Espresso" everything looks like it should be in iOS 5 Simulator but if I run the App in iOS 6 Simulator the text gets truncated after the first line although the text goes over 3 lines. Number of lines are set to zero. Did I miss something? After I noticed this behavior in the Espresso App I can stop worrying about the brokeness of the code in my own app.
Any suggestions? Thanks!
I currently faced the same problem. Try setting the LineBreakMode before you actually set your text. E.g.:
TTTAttributedLabel* descriptionLabel = [[TTTAttributedLabel alloc] initWithFrame:CGRectMake(20, 120, 280, expectedSize.height)];
descriptionLabel.lineBreakMode = UILineBreakModeWordWrap;
descriptionLabel.numberOfLines = 0;
descriptionLabel.text = description;
Labels and textviews in iOS 6 support attributed text natively. So if you don't need to support older versions of iOS, you can get rid of 3rd party control.
In my case, for some reason following code was causing the label to show only one row. Removing it helped
' self.attributedLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;'
Strangely the problem solved itself. I could not figure out why this particular problem happened on iOS6 Simulator but now it works with NSLineBreakTailTruncation on iOS6 Device and Simulator.
Thank you for your responses!
You can have a try.
NSMutableAttributedString * mutableAttributedString = [[NSMutableAttributedString alloc]initWithString:text];
[self.attributedLabel setText:mutableAttributedString afterInheritingLabelAttributesAndConfiguringWithBlock:nil];