Solved! Declare 2 instance variables: selectedView, and oldView. Then the following code does the trick: if (self.
OldView! = nil) self.oldView. BackgroundColor = UIColor clearColor; self.
SelectedView = picker viewForRow:row forComponent:kNumberComponent; self.selectedView. BackgroundColor = UIColor redColor; self. SelectedView setNeedsDisplay; self.
OldView = self.selectedView.
Thanks :) – Mayur Birari Apr 29 at 11:32.
It's unclear where you are putting the above code. Is it in -pickerView:viewForRow:forComponent:reusingView:? This is where it should be.
Are you sure that you are maintaining a pointer to the label for that particular view? The fact that you are crashing suggests you probably are not. A larger block of code, including where you have put it, would be helpful.
Rob, I've posted the full method thanks again for any suggestions! – ennuikiller May 22 '09 at 0:14 I think you've misunderstood how this delegate methods works. The pickerView is giving you a reusingView.
You're modifying it with -addSubView:, but you're returning a different view (the UILabel). The first thing you should do here is get rid of the calls to -addSubView:. – Rob Napier May 22 '09 at 2:43.
Call the UIPickerView instance's -viewForRow:forComponent: method to get the UIView * object. Then set that view's background UIColor.
I beleive I've tried that already, but I've give it another go – ennuikiller May 22 '09 at 0:17 Also make sure you have set your UIView (containing the UIPickerView) as the pickerview's delegate, and that you have specified that the UIView will implement the UIPickerViewDelegate contract. – Alex Reynolds May 22 '09 at 0:21 I've got the code above in the pickerviewcontroller and have set the pickerview. Delegate = self in the loadView method.
I tried in the didSelectRow method: UIView *selectedView = numberFactsPicker viewForRow:numberRow forComponent:kFactComponent; selectedView. BackgroundColor = UIColor redColor; somehow I think I would need to add it back as a subview maybe? – ennuikiller May 22 '09 at 0:30 Maybe you can check if *selectedView is nil.
Maybe something is not wired up right. Perhaps use the debugger or NSLog statements to check the values of things, as well as to make sure that your delegate methods are being called. – Alex Reynolds May 22 '09 at 0:42 Setting the viewForRow's background color works-mostly but, in the case of the first and last item, you can still see the picker's white background, "off the edge of the reel."
Sadly, setting myPickerView setBackGroundColor:UIColor blackColor (or any color) doesn't do what one might hope. – Olie 30 May8 at 18:50.
The correct format for viewForPicker is: - (UIView *)pickerView:(UIPickerView *)pickerView viewForRow:(NSInteger)row forComponent:(NSInteger)component reusingView:(UIView *)view { UILabel *label = (UILabel*) view; if (label == nil) { label = UILabel alloc init; } label setText:@"Whatever"; // This part just colorizes everything, since you asked about that. Label setTextColor:UIColor whiteColor; label setBackgroundColor:UIColor blackColor; CGSize rowSize = pickerView rowSizeForComponent:component; CGRect labelRect = CGRectMake (0, 0, rowSize. Width, rowSize.
Height); label setFrame:labelRect; return label; } The problem with the code above is: it colorizes the labels, but not the picker, itself. So, when you roll to one end or the other, there's a blank spot where you can see the white background. Setting myPicker setBackgroundColor... doesn't do what one might hope.
Iphone - How to change color of selected row in UIPickerView - Stack Overflow.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.