PickerView problem



  • #import <UIKit/UIKit.h>
    
    @interface ListProc : UIViewController<UIPickerViewDataSource, UIPickerViewDelegate>
    {
        IBOutlet UIPickerView *m_pPickerView;
        IBOutlet UITextField *m_val1;
        IBOutlet UITextField *m_val2;
        IBOutlet UILabel *m_resText;
        IBOutlet UILabel *m_res;
        IBOutlet NSString *m_text;
    }
    @property(retain,nonatomic) UITextField *m_val1;
    @property(retain,nonatomic) UITextField *m_val2;
    @property(retain,nonatomic) UILabel *m_resText;
    @property(retain,nonatomic) UILabel *m_res;
    @property(retain,nonatomic) UIPickerView *m_pPickerView;
    @property(retain,nonatomic) NSString *m_text;
    -(IBAction)onTextChanged:(id)sender;
     /users/880/endre 
    

    ListProc.m

    #import "ListProc.h"
    

    @implementation ListProc
    @synthesize m_pPickerView;
    @synthesize m_res;
    @synthesize m_val1;
    @synthesize m_val2;
    @synthesize m_resText;
    @synthesize m_text;

    • (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
      {
      self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
      if (self) {
      // Custom initialization
      }
      return self;
      }

    -(NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView
    {
    return 1;
    }

    • (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component
      {
      return 10;
      }

    -(void) CalcAll
    {

    if((m_text.length &gt; 0) &amp;&amp; (m_val1.hasText) &amp;&amp; (m_val2.hasText))
    {
        float massa;
        if(m_text == @"6")
            massa = 0.222;
        else if(m_text == @"8")
            massa = 0.395;
        else if(m_text == @"10")
            massa = 0.617;
        else if(m_text == @"12")
            massa = 0.888;
        else if(m_text == @"14")
            massa = 1.21;
        else if(m_text == @"16")
            massa = 1.58;
        else if(m_text == @"18")
            massa = 2;
        else if(m_text == @"20")
            massa = 2.47;
        else if(m_text == @"22")
            massa = 2.98;
        else if(m_text == @"25")
            massa = 3.85;
        else if(m_text == @"28")
            massa = 4.83;
        else if(m_text == @"32")
            massa = 6.31;
        else if(m_text == @"36")
            massa = 7.99;
        else if(m_text == @"40")
            massa = 9.87;
        else if(m_text == @"45")
            massa = 12.48;
        else if(m_text == @"50")
            massa = 15.41;
        else if(m_text == @"55")
            massa = 18.65;
        else if(m_text == @"60")
            massa = 22.19;
    
        int val1 = [m_val1.text intValue];
        int val2 = [m_val2.text intValue];
        float res = val1 * val2 * massa;
        m_resText.text = [NSString stringWithFormat:@"%d", res];
    }
    

    }
    -(IBAction)onTextChanged:(id)sender
    {
    [self CalcAll];
    }

    -(void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component
    {
    NSString *text = [self pickerView:m_pPickerView titleForRow:row forComponent:component];
    m_text = text;
    [self CalcAll];

    }

    -(NSString*) pickerView:(UIPickerView*)thePickerView
    titleForRow:(NSInteger)row forComponent:(NSInteger)component
    {
    NSArray *data = [NSArray arrayWithObjects:@"6",@"8",@"10",@"12",@"14",@"16",@"18",@"20",@"22",@"25",nil ];
    return [data objectAtIndex:row];
    }

    • (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

    /*
    // Implement loadView to create a view hierarchy programmatically, without using a nib.

    • (void)loadView
      {
      }
      */

    /*
    // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

    • (void)viewDidLoad
      {
      [super viewDidLoad];
      }
      */

    • (void)viewDidUnload
      {
      [super viewDidUnload];
      // Release any retained subviews of the main view.
      // e.g. self.myOutlet = nil;
      }

    • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
      {
      // Return YES for supported orientations
      return (interfaceOrientation == UIInterfaceOrientationPortrait);
      }

    /users/880/endre

    Problem is, when I start changing the picer, the attachment stops and hits the line
    if(m_text.length der 0) &quot; (m_val1.hasText) &quot; (m_val2.hasText)



  • Thread 1: stopped at breakpoint 1 It's not a mistake. Go into the breakpoints deposit and delete it.


Log in to reply
 


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2