UISlider + UIPicker

Z

Zmash

Registriert
Thread Starter
Dabei seit
03.04.2011
Beiträge
1
Reaktionspunkte
0
HI,
ich bin relative neu in der App entwicklung und wollte fragen, ob mir jemand bei folgenden Problem helfen kann?

Ich möchte das der inhalt von textView2(ist das ausgabe UILabel vom Picker) mit dem Silderwert multipliziert wird und das ganze dann in textView(einfaches UILabel) ausgegeben wird. (die alleinige Ausgabe von Slider oder Picker schaffe ich, nur das Zusammenführen halt nicht)

hier mein code versuch...

Code:
#import "SliderTestViewController.h"

int c;

@implementation SliderTestViewController

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

- (NSInteger)pickerView:(UIPickerView *)thePickerView numberOfRowsInComponent:(NSInteger)component {
	
	return [list count];
}

- (NSString *)pickerView:(UIPickerView *)thePickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component {
	
	return [list objectAtIndex:row];
}

- (void)pickerView:(UIPickerView *)thePickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component {
	
	b = (textView2.text)
	
	if (row == 0) {
		textView.text = @"1";
		textView2.text = @"4";
	}
	
	else if (row == 1) {
		textView.text = @"2";
		textView2.text = @"5";
		
	}
	
	else if (row == 2) {
		textView.text = c;
		textView2.text = @"6";
		
	}
	
		NSLog(@"Selected item: %@. Index of selected item %i", [list objectAtIndex:row], row);
	
}

-(IBAction) sliderChanged: (id)sender {
	UISlider *slider = (UISlider *)sender;
	int progressAsInt = (int)(slider.value + 0.5f);
	NSString *newText = [[NSString alloc] initWithFormat:@"%d", progressAsInt];
	sliderLabel.text=newText;
    a = (slider.value)
	[newText release];
}	

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}
*/

/*
// 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];
 
 list = [[NSMutableArray alloc] init];
 [list addObject:@"eins"];
 [list addObject:@"zwei"];
 [list addObject:@"drei"];
}



/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (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.
}

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


- (void)dealloc {
    [super dealloc];
}

@end
}

hoffe man versteht was ich will :)

Liebe grüße Zmash
 
Zurück
Oben Unten