Drawing App

Discussion in 'iOS Programming' started by SunnyLi, Oct 12, 2010.

  1. SunnyLi Guest

    Joined:
    Oct 7, 2010
    #1
    Hi Guys,

    Back again as you were really helpful last time :)

    Im following a tutorial on creating a whiteboard drawing app, but everytime i insert a certain piece of code it crashes the app when i go to the settings button.

    This is the code:
    .h

    Code:
    //
    //  FlipsideViewController.h
    //  SampleBrushes
    //
    //  Created by Andrea Busi on 01/03/10.
    //  Copyright BubiDevs 2010. All rights reserved.
    //
    
    @protocol FlipsideViewControllerDelegate;
    
    
    @interface FlipsideViewController : UIViewController {
    	id <FlipsideViewControllerDelegate> delegate;
    	
    	IBOutlet UISlider *sliderRed, *sliderBlue, *sliderGreen, *sliderBlack, *sliderDimension;
    	IBOutlet UIImageView *viewColour;
    	IBOutlet UILabel *labelDimension;
    	
    	UIColor *penColour;
    	float penDimension;
    }
    
    @property (nonatomic, assign) id <FlipsideViewControllerDelegate> delegate;
    @property (nonatomic, assign) UIColor *penColour;
    @property (nonatomic, assign) float penDimension;
    
    - (IBAction)done;
    - (IBAction)changeColour;
    - (IBAction)changeDimension;
    
    @end
    
    
    @protocol FlipsideViewControllerDelegate
    - (void)flipsideViewControllerDidFinish:(FlipsideViewController *)controller newColour:(UIColor*)colore newDimension:(float)dimension;
    @end
    
    
    flipsideviewcontroller.m

    Code:
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
    	
    	const CGFloat *components = CGColorGetComponents([colorePennello CGColor]);
    	[sliderRed setValue:components[0]];
    	[sliderGreen setValue:components[1]];
    	[sliderBlue setValue:components[2]];
    	[sliderBlack setValue:components[3]];
    	[viewColore setBackgroundColor:colorePennello];
    	labelDimensione.text = [NSString stringWithFormat:@"%f",dimensionePennello];
    	[sliderDimensione setValue:dimensionePennello];
    }
    The tutorial is here:

     
  2. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #2
    When you insert which certain piece of code? All of what you posted? When the app crashes do you see any error messages in the console? Have you checked the crash log?
     
  3. PhoneyDeveloper macrumors 68030

    PhoneyDeveloper

    Joined:
    Sep 2, 2008
    #3
    How come the top code is in English and the bottom code is in Italian?

    Anyway, your penColor property should be retain, not assign. This would likely cause a crash.
     
  4. SunnyLi thread starter Guest

    Joined:
    Oct 7, 2010
    #4
    The tutorials in Italian im just puting it into english.

    I put breakpoint in just it stops here:

    Code:
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor = [UIColor viewFlipsideBackgroundColor];
    	
    	const CGFloat *components = CGColorGetComponents([penColour CGColor]);
    	[B][sliderRed setValue:components[0]];[/B]
    	[sliderGreen setValue:components[1]];
    	[sliderBlue setValue:components[2]];
    	[sliderBlack setValue:components[3]];
    	[viewColour setBackgroundColor:penColour];
    	labelDimensions.text = [NSString stringWithFormat:@"%f",penDimension];
    	[sliderDimension setValue:penDimension];
    
    	
    }
    not sure how to get up the crash logs etc
     
  5. dejo Moderator

    dejo

    Staff Member

    Joined:
    Sep 2, 2004
    Location:
    The Centennial State
    #5
    No error message in the Debugger?
     

Share This Page