I have UIScrollViewinside, some views are loaded from an xib file.
UIScrollViewonly loads three Views. Current, left and right.
For example, I have one view to the left and one view to the right of the current one View. If I scroll to the right, UIScrollViewdelete the view on the left, scroll right to the new current one Viewand load the new view to the right of the new current one View.
In addition, I have a button outside UIScrollView. When I click on it, it changes the background color of the current view displayed on UIScrollView.
This works well, but sometimes, I don’t know why, when I click the button to change the background color in the view, it changes well, but the view does not refresh, so the user cannot see the background color change.
UIScrollView:
container = [[UIScrollView alloc] initWithFrame:frame];
[container setBackgroundColor:[UIColor clearColor]]
[container setCanCancelContentTouches:NO]
[container setClipsToBounds:NO]
[container setShowsHorizontalScrollIndicator:NO]
[container setPagingEnabled:YES]
Method call when I press the button to change the background color of the current view
- (void)menuColor:(MenuPickerViewController *)controller didPickOption:(UIView *)button
{
MyProduct *product = (MyProduct *)[MyProduct getProduct:[_slider getCurrentContentDisplayed]];
ColorButtonMenu *colorView = (ColorButtonMenu *)[button superview];
MyView *myView = (MyView *)[self sliderGetViewWithID:[_slider getCurrentContentDisplayed] FromSlider:_slider];
product.color = colorView.color;
IFPrint(@"myView.border backgorund color before: %@\n", myView.border.backgroundColor.description);
[myView.border setBackgroundColor:[Utilities colorFromHexString:colorView.color]];
[myView.border setNeedsDisplay];
IFPrint(@"myView.border backgorund color after: %@\n", myView.border.backgroundColor.description);
IFPrint(@"=== DEBUG ===\n");
IFPrint(@"isMainThread ? : %i\n", [NSThread isMainThread]);
IFPrint(@"myView: %@\n", myView);
IFPrint(@"myView border: %@\n", myView.border);
IFPrint(@"=============\n\n");
}
So, as you can see at the end of the method, I tried to call the method setNeedsDisplayin the view loaded from xib, and the other view is inside the "border", but nothing works. In addition, my method is always called on the main thread.
Any suggestions?
Thanks!
Edit:
Obviously, I checked if the return view sliderGetViewWithID is the correct view. All attributes are well set. In my opinion, this is really an update problem.