I wanted to make a button that will flip between 2 different stages by changing the test. So if it says add, you click on i changes to remove. If it says remove it will change to add.
The program did not work,
to try and debug it, I put the setTitle method in oncreate, it worked there. Next I set break point in my method. It detected it said add, and executed the line that is suppose to change the text, the text did not change. I’m really don’t understand why it works on the oncreate method and not my method.
Code
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
mFeetImage.contentMode = UIViewContentModeScaleAspectFit;
[gFileName Reset];
NSString *ted= [gFileName GetFileName];
mFeetImage.image= [ UIImage imageNamed :ted];
// test code
[ mFavrest setTitle: @"ADD" forState:UIControlStateNormal ]; works
}
-(IBAction) aFavest: (id) sender
{
NSString *t=mFavrest.currentTitle;
int i=[ t compare:@"ADD" ];
if ( i ==0 )
{
// set break point here, break point goes off text does not change
[ mFavrest setTitle: @"REMOVE" forState:UIControlStateNormal ];
}
else
{
[ mFavrest setTitle: @"ADD" forState:UIControlStateNormal];
}
}
Try the following code:
Also, make sure the variable
mFavrestis properly connected. Put a break point somewhere and check if it isnt nil.If the IBOutlet mFavrest is connected properly and the IBAction is as well, this code should work.