I have a UITextView which should auto detect phone numbers. The detection works fine, however if the text is changed the link will call the previous number, even though the actual text has changed. What is the problem? Is this another iOS 7 bug (I have experienced quite a few with UITextView?
This is a bug in iOS 7.
What you can try is resetting the text to nil, before setting the new string.
_textView.text = nil;
_textView.text = yourText;
This will reset the text view and correct phone number detection should work again.
Related
I have a label which shows the pink area on the screen. However, the word "gender " is not shown in the top line even if it has enough space. Why is it not showing up in the first line itself? What I need
label.text = #"Do you believe in gender equality";
Label
The UILabel is working as intended by preventing an orphaned word so it’s more readable. This was introduced in iOS 11. Apple must disable it for iMessage because they probably intend this behaviour for long articles of text, not text messages.
I've seen fixes including
call sizeToFit on the label after the text has been set
setting UserDefaults.standard.set(false, forKey: "NSAllowsDefaultLineBreakStrategy") // Using this private tricky shortcut may leads appstore rejection.
But none of these are working on iOS 13, simulator (Not tested on devices).
Fix
One tricky solution is - append some spaces or two tabs("\t\t") to the text and set programatically.
Use following code:
label.lineBreakStrategy = []
So, Apple has a bug right now where if you type an Emoji into a UITextField, it will shift the text down. In fact, if you type enough emojis and then backspace, it'll shift the text even further down from where it was supposed to be. I confirmed this by trying UITextFields in Twitter, Snapchat and other apps.
Here is a video of my app displaying the bug.
Use this: textField.clipsToBounds = false
It prevents the textField to move when editing. Even when you try to edit it again.
(Tested on iPhone 6, iOS 10.0)
I don't think their would be a way around this, as it just seems that the emoji is changing the margin of the text inside of the UITextField.
I have an iOS application that looks up employees and shows their work number/mobile number. The problem I am having is after looking up one person and then another, when I click on the number of the person I just looked up, it keeps calling the number of the previously searched person.
And before anyone says anything, I have looked at UITextView link detection in iOS 7
I have tried setting the textview.text = nil, disabling and enabling selectable, editable and scrollEnabled. Nothing has worked. If anyone could please shed some light on the problem I am having, that would be great. Thank you!
Lookup 1st employee, click on phone# and it calls correct number
Lookup another employee (2nd employee), shows correct phone#, click on phone# and it calls 1st employee's phone#
Lookup another employee (3rd employee), shows correct phone#, click on phone# and it still calls 1st employees phone#.
the UITextView has selectable = true, detection = phone numbers, editable = NO, have tried setting scroll enabled = YES and NO.
iOS Deployment target is 7.0
Code:
#property (weak,nonatomic) IBOutlet UITextView *Phone;
found = [happyArray valueForKey:#Extension"];
if ([found length]>0) _Phone.text = [NSString stringWithFormat:#"%#",[found stringByTrimmingCharactersInSet: [NSCharacterSet whitespaceCharacterSet]]];
This appears to be an iOS bug, like it mentions in this other answer of SO. Try setting the text view to editable and then unsetting it just after setting the new number.
If that doesnt work, use setText:nil before setting the number again.
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.
I've got two UITextViews containing data that should be recongised by the data detection, however whilst one works fine on both device and simulator there's one that only works under Simulator. I've attempted trashing the build from my device, cleaning the product down, removing derived data and nothing seems to resolve the inconsistency.
Link detection was enabled within Interface Builder, the data is passed in with a NSString stringWithFormat: formatted string and set with UITextView setText:. Set the same way for both, so there's no difference there, but it just doesn't seem to work correctly for one of them.
EDIT: On the device if I tap on one of the items that should detect as a link, it'll then turn blue and do link detection. I'm not setting any custom fonts or colours that could have an impact.
It appears that the trick is to setScrollable:NO. Seems to fix the problem, although if you need scrolling, I'm not sure what the answer will be...
Apparently this issue is caused by how iOS is currently handling the UITextView links. It is creating an NSAttributedString that turns sections of the text blue ( when the view contains a link ). So I've figured out that this bug only occurs when a link is the first text in the AttributedString, i.e. the first text in the text view. So it's easily fixed by prepending an whitespace to your text before setting it. Or overriding setText to " " + text;
Hope this helps guys