2017-01-02 49 views
-1

該應用程序的本質是與當前日期進行比較,並指定每天的輸出文本(祈禱時間)。 問題:當應用程序在當天顯示的背景文本中。如果關閉應用程序並在所有節目正確後打開。重新從後臺喚醒時的代碼

ViewController.h

@interface ViewController : UIViewController 

@property (weak, nonatomic) IBOutlet UITextField *utr; 
@property (weak, nonatomic) IBOutlet UITextField *voskh; 
@property (weak, nonatomic) IBOutlet UITextField *obed; 
@property (weak, nonatomic) IBOutlet UITextField *predz; 
@property (weak, nonatomic) IBOutlet UITextField *vecher; 
@property (weak, nonatomic) IBOutlet UITextField *noch; 

ViewController.m

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar]; 
    NSDateComponents *comp0 = [[NSCalendar autoupdatingCurrentCalendar] components:NSCalendarUnitEra | NSCalendarUnitMonth | NSCalendarUnitDay fromDate:[NSDate date]]; 

    NSDateComponents *comp1 = [calendar components:(NSCalendarUnitDay | NSCalendarUnitMonth) fromDate:[NSDate date]]; 
    NSDateComponents *comp2 = [calendar components:(NSCalendarUnitDay | NSCalendarUnitMonth) fromDate:[NSDate date]]; 
    NSDateComponents *comp3 = [calendar components:(NSCalendarUnitDay | NSCalendarUnitMonth) fromDate:[NSDate date]]; 
    NSDateComponents *comp4 = [calendar components:(NSCalendarUnitDay | NSCalendarUnitMonth) fromDate:[NSDate date]]; 

    [comp1 setDay:1]; [comp1 setMonth:1]; 
    [comp2 setDay:2]; [comp2 setMonth:1]; 
    [comp3 setDay:3]; [comp3 setMonth:1]; 
    [comp4 setDay:4]; [comp4 setMonth:1]; 

    if([comp1 day] == [comp0 day] && 
     [comp1 month] == [comp0 month]) { 

     [email protected]"05:44"; [email protected]"07:19"; [email protected]"11:58"; [email protected]"14:12"; [email protected]"16:31"; [email protected]"18:01"; 
    } 

    if([comp2 day] == [comp0 day] && 
     [comp2 month] == [comp0 month]) { 

     [email protected]"05:44"; [email protected]"07:19"; [email protected]"11:58"; [email protected]"14:13"; [email protected]"16:31"; [email protected]"18:01"; 
    } 

    if([comp3 day] == [comp0 day] && 
     [comp3 month] == [comp0 month]) { 

     [email protected]"05:44"; [email protected]"07:19"; [email protected]"11:59"; [email protected]"14:14"; [email protected]"16:32"; [email protected]"18:02"; 
    } 

    if([comp4 day] == [comp0 day] && 
     [comp4 month] == [comp0 month]) { 

     [email protected]"05:44"; [email protected]"07:19"; [email protected]"12:00"; [email protected]"14:15"; [email protected]"16:33"; [email protected]"18:03"; 
    } 

回答

相關問題