我想在应用程序进入前台时更改视图控制器中的标签....:
SalaryAppV4AppDelegate.h
@interface SalaryAppV4AppDelegate:NSObject {
// --------------------------------------------- -
NSTimeInterval appEnteredBackground;
NSTimeInterval appEnteredForeground;
NSTimeInterval difference;
NSString *times;
// --------------------------------------------- -
SalaryAppV4AppDelegate.m
{
//perform -(IBAction)DoThis
FirstViewController* controller = [FirstViewController alloc];
[controller DoThis];
//releasing
[dateFormatter release];
}
// --------------------------------------------- ------------------------
FirstViewController.h
导入UIKit / UIKit.h> 导入“SalaryAppV4AppDelegate.h”
@interface FirstViewController:UIViewController {
IBOutlet UITextField *text1;
IBOutlet UILabel *label;
IBOutlet UILabel *labeltotal;
IBOutlet UILabel *differenceLabel;
int i;
float number1;
NSTimer *timer;
SalaryAppV4AppDelegate *appDelegate;
}
//操作
- (IBAction为)复位:(ID)发送者;
- (IBAction为)backgroundTouched:(ID)发送者;
- (IBAction)beginTimer;
- (void)DoThis;
//属性
@end
// --------------------------------------------- -----------------------
FirstViewController.m
- (IBAction)DoThis {
appDelegate = [[[UIApplication sharedApplication] delegate] retain];
//This Doesn't Work :(
label.text = @"IT Has Worked";
//This Works
NSLog(@"%@", appDelegate.times);
}
// --------------------------------------------- -----------
我只想将label.text ti更改为任何内容,但在viewcontroller更改中没有任何内容......