Fa Hu Fa Hu - 10 months ago 83
Objective-C Question

Set UIButton text

It is my text label:

@property (strong, nonatomic) IBOutlet UILabel *textEmail;

_titleGet = [_dictionaryGeter objectForKey:@"Email"];
_textEmail.text= _titleGet;

objectForKey:@"Email" from plist

I want to make button. How to make that button title to be equal to the textEmail?

Answer Source

There are two ways to set the title of a UIButton.

Option 1 (the wrong way): myButton.titleLabel.text = myString

Option 2 (the right way): [myButton setTitle:myString forState:UIControlStateNormal];

So, your code would be:

_titleGet = [_dictionaryGeter objectForKey:@"Email"];
[_btn setTitle:_titleGet forState:UIControlStateNormal];