每当我点击我的iphone应用程序中的segmentedControl时,我都会遇到EXC_BAD_ACCESS。
我正在使用名为PPiFlatSegmentedControl(https://github.com/pepibumur/PPiFlatSegmentedControl)的OSS库。这是我的代码初始化段:
- (void)setupSegmentedControl {
// open source library - PPiFlatSegmentedControl
PPiFlatSegmentedControl *segmentedControl = [[PPiFlatSegmentedControl alloc] initWithFrame:CGRectMake(0, 42, 320, 40) items:@[
@{@"text":@"ALL"},
@{@"text":@"COMPLETED"},
@{@"text":@"UNCOMPLETED"}] iconPosition:IconPositionRight andSelectionBlock:^(NSUInteger segmentIndex) {
switch (segmentIndex) {
case 0:
// All
//[self enableFilters];
[tasks addObjectsFromArray:[[CoreDataManager sharedInstance] fetchTaskList]];
break;
case 1:
// Complete
[tasks addObjectsFromArray:[[CoreDataManager sharedInstance] fetchTasksByCompletion:YES]];
break;
case 2:
// Uncompleted
[tasks addObjectsFromArray:[[CoreDataManager sharedInstance] fetchTasksByCompletion:NO]];
break;
default:
break;
}
}];
segmentedControl.color=[UIColor colorWithRed:45.0f/255.0 green:203.0f/255.0 blue:116.0f/255.0 alpha:1];
segmentedControl.borderWidth=0.5;
segmentedControl.borderColor=[UIColor darkGrayColor];
segmentedControl.selectedColor=[UIColor colorWithRed:36.0f/255.0 green:190.0f/255.0 blue:104.0f/255.0 alpha:1];
segmentedControl.textAttributes=@{NSFontAttributeName:[UIFont systemFontOfSize:13],
NSForegroundColorAttributeName:[UIColor whiteColor]};
segmentedControl.selectedTextAttributes=@{NSFontAttributeName:[UIFont systemFontOfSize:13],
NSForegroundColorAttributeName:[UIColor whiteColor]};
[self.view addSubview:segmentedControl];
所以,每当我点击其中一个单元格/按钮时,我就会收到该错误。请记住,我的项目目前没有ARC - 所以我真的有一种感觉我正在错误地管理内存。如果您需要更多信息或其他任何信息 - 请告诉我!
-Matt