I have UITextView *_masterText
and after call method setText
property font is being reset.
It's happening after I change sdk 7.
_masterText is IBOutlet
, global and properties are set in storyboard. It's only me or this is general SDK bug?
@interface myViewController : UIViewController
{
IBOutlet UITextView *_masterText;
}
@implementation myViewController
-(void)viewWillAppear:(BOOL)animated
{
[_masterText setText:@"New text"];
}
Using the work-around discussed in this issue, this extension to UITextView provides a
setTextInCurrentStyle()
function. Based on solution by Alessandro Ranaldi but does not require the current isSelectable value to be passed to the function.Here's a quick subclass solution I often use for this problem.
Had this issue myself and the above answer helped but I added a wrapper to my ViewController code as follows and just pass the uiview instance and text to change and the wrapper function toggles the Selectable value on, changes text and then turns it off again. Helpful when you need the uitextview to be off at all times by default.
I ran into the same issue (on Xcode 6.1) and while John Cogan's answer worked for me, I found that extending the UITextView class with a category was a better solution for my particular project.
interface
implementation
In iOS 8.3, the workaround of setting "selectable" to YES before the setText, and NO after, didn't fix it for me.
I found I needed to set "selectable" to YES in the storyboard, too, before this would work.
This worked for me: