Resolved Why isn't my timer changing fonts?

Discussion in 'iOS Programming' started by EducationApp, Aug 19, 2011.

  1. EducationApp, Aug 19, 2011
    Last edited: Aug 19, 2011

    EducationApp macrumors newbie

    Joined:
    Aug 17, 2011
    #1
    It is supposed to change to Speedline but it isn't working...
    Code:
    #import <UIKit/UIKit.h>
    
    @interface easyview : UIViewController {
        
        NSTimer *timer;
        
        int MainInt;
        
        UILabel *infoText;
        IBOutlet UILabel *label;
    
        
    }
    
    @property (nonatomic, retain) IBOutlet UILabel *infoText;
    
    
    -(IBAction)delay:(id)sender;
    
    -(void)countdown;
    -(void)delay;
    
    
    @end
    
    Code:
    #import "easyview.h"
    #import "secondview.h"
    
    @implementation easyview
    @synthesize infoText;
    
    -(IBAction)switchback1:(id)sender {
        secondview *second = [[secondview alloc] initWithNibName:nil bundle:nil];
        [self presentModalViewController:second animated:YES];
    }
    
    -(void)countdown {
        MainInt -= 1;
        infoText.text = [NSString stringWithFormat:@"%i", MainInt];
        
    }
    
    
    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
        if (self) {
            // Custom initialization
        }
        return self;
    }
    
    - (void)didReceiveMemoryWarning
    {
        // Releases the view if it doesn't have a superview.
        [super didReceiveMemoryWarning];
        
        // Release any cached data, images, etc that aren't in use.
    }
    
    #pragma mark - View lifecycle
    
    - (void)viewDidLoad
    {
        [self performSelector:@selector(delay) withObject:nil afterDelay:1.5];
        [super viewDidLoad];
    
        // Do any additional setup after loading the view from its nib.
    }
    
    -(void)delay {
        MainInt = 60;
        timer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(countdown) userInfo:nil repeats:YES];
    }
    
    - (void)viewDidUnload
    {
        [label setFont:[UIFont fontWithName:@"Speedline" size:24]];
        [super viewDidLoad];
        infoText.text = @"60";
        [super viewDidLoad];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }
    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
    }
    
    @end
    
     
  2. Shawnpk macrumors 6502

    Joined:
    Jan 13, 2011
    Location:
    Los Angeles, CA
    #2
    It looks like you have your code in the wrong place. You are coding things in viewDidUnload that should be in viewDidLoad (I'm guessing).
     
  3. ArtOfWarfare macrumors G3

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #3
    In addition to what Shawnpk said, I'd like to add that "Speedline" probably isn't a valid font name, unless you've added a custom font to your app.
     
  4. EducationApp thread starter macrumors newbie

    Joined:
    Aug 17, 2011
    #4
    Yeah, I did add a custom font to the info.plist.
    I can't believe I missed such a simple, stupid mistake.
    Thanks a bunch guys.
     

Share This Page