任何人都可以帮助我解决这个错误。我尝试了很多,但每次都得到相同的错误。
NSMutableArray *temp_array;
- (void)viewDidLoad
{
//... other code
NSArray *dataarray = [[[mydata objectAtIndex:0] objectForKey:@"concept"] componentsSeparatedByString:@";"];
temp_array = [[dataarray mutableCopy] autorelease];
}
-(void) setTitle:(NSString *)design_no
{
productLbl.text = [[NSString stringWithFormat:@"%@",[temp_array objectAtIndex:[design_no intValue]]] autorelease];
// I got error at this place like EXC_BAD_ACCESS(Code=2,address=0x8) thread cause while runtime.
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)sender{
CGFloat pageWidth = sender.frame.size.width;
int page = floor((sender.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
if (page==previousPage_) {
return;
}
//incase we are still in same page, ignore the swipe action
[self setTitle:[NSString stringWithFormat:@"%i",page]];
}
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollViewd;{
CGFloat pageWidth = scrollViewd.frame.size.width;
previousPage_ = floor((scrollViewd.contentOffset.x - pageWidth / 2) / pageWidth) + 1;
}
我只是在滚动视图中滚动页面时不会更改 LABLE 文本。