reloadData doesn't work though when changing data
fusjh2o opened this issue · comments
thanks for creating V8HorizontalPickerView. Using (UIView *)horizontalPickerView:(V8HorizontalPickerView *)picker viewForElementAtIndex:(NSInteger)index, 'reloadData" doesn't work thought when changing data.
Answer:
we need change -(void)dealloc{}.and -(id) initWithFrame:(CGRect) frame. as follows:
pragma mark - Init/Dealloc
-
(id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
elementWidths = [[NSMutableArray array] retain];_scrollView = nil;//防止系统crash [self addScrollView]; self.textColor = [UIColor blackColor]; self.elementFont = [UIFont systemFontOfSize:12.0f]; currentSelectedIndex = -1; // nothing is selected yet numberOfElements = 0; elementPadding = 0; dataHasBeenLoaded = NO; scrollSizeHasBeenSet = NO; scrollingBasedOnUserInteraction = NO; // default to the center selectionPoint = CGPointMake(frame.size.width / 2, 0.0f); indicatorPosition = V8HorizontalPickerIndicatorBottom; firstVisibleElement = -1; lastVisibleElement = -1; scrollEdgeViewPadding = 0.0f; self.autoresizesSubviews = YES;
}
return self;
}
if 0 //code from network. but releadData, crash.
-
(void)dealloc {
_scrollView.delegate = nil;[_scrollView release];
[elementWidths release];
[elementFont release];
[leftEdgeView release];
[rightEdgeView release];[leftScrollEdgeView release];
[rightScrollEdgeView release];[textColor release];
[selectedTextColor release];if (selectionIndicatorView) {
[selectionIndicatorView release];
}[super dealloc];
}else
-
(void)dealloc {
_scrollView.delegate = nil;[_scrollView release];
_scrollView = nil;[elementWidths release];
elementWidths = nil;[elementFont release];
elementFont = nil;[leftEdgeView release];
leftEdgeView = nil;[rightEdgeView release];
rightEdgeView = nil;[leftScrollEdgeView release];
leftScrollEdgeView = nil;[rightScrollEdgeView release];
rightScrollEdgeView = nil;[textColor release];
textColor = nil;[selectedTextColor release];
selectedTextColor = nil;if (selectionIndicatorView) {
[selectionIndicatorView release];
selectionIndicatorView = nil;
}[super dealloc];
}endif
. more, thanks for veader.
i‘ve got the same issue~ reload doesn't work
I have committed an additional branch tonight in hopes of finding what might be causing your problem. In all of the demo branches, I have a button that when tapped, changes the data and then calls reloadData.
Can you point me to some sample code of what you are doing and how it's not working? If not code, could you provide some additional background information? Would love to help sort this out.
gonna go ahead and close this one. please let me know if you have some additional information that could help me understand what's going on.