当应用程序进入前台时,我想更改视图控制器中的标签....:
SalaryAppV4AppDelegate.h
@interface SalaryAppV4AppDelegate : NSObject {
//----------------------------------------------------------
NSTimeInterval appEnteredBackground;
NSTimeInterval appEnteredForeground;
NSTimeInterval difference;
NSString *times;
//------------------------------------------------
SalaryAppV4AppDelegate.m
- (void)applicationWillEnterForeground:(UIApplication *)application
{
//perform -(IBAction)DoThis
FirstViewController* controller = [FirstViewController alloc];
[controller DoThis];
//releasing
[dateFormatter release];
}
//------------------------------------------------ ---------------------
第一视图控制器.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)sender;
-(IBAction)开始计时器;
-(无效)这样做;
//特性
@结尾
//------------------------------------------------ --------------------
第一视图控制器.m
-(IBAction)这样做{
appDelegate = [[[UIApplication sharedApplication] delegate] retain];
//This Doesn't Work :(
label.text = @"IT Has Worked";
//This Works
NSLog(@"%@", appDelegate.times);
}
//------------------------------------------------ --------
我只想将 label.text ti 更改为任何内容,但 viewcontroller 中没有任何更改...