当我想更改它的形状或颜色时,iPhone 上的段控制器有一些问题,它会抛出错误
#import "BIDViewController.h"
#import "BIDQuartzFunView.h"
#import "BIDConstants.h"
@interface BIDViewController ()
@end
@implementation BIDViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)changeColor:(id)sender {
UISegmentedControl *control = sender;
NSInteger index = [control selectedSegmentIndex];
BIDQuartzFunView *funView = (BIDQuartzFunView *)self.view;
switch (index) {
case kRedColorTab:
funView.currentColor = [UIColor redColor];
funView.useRandomColor = NO;
break;
case kBlueColorTab:
funView.currentColor = [UIColor blueColor];
funView.useRandomColor = NO;
break;
case kYellowColorTab:
funView.currentColor = [UIColor yellowColor];
funView.useRandomColor = NO;
break;
case kGreenColorTab:
funView.currentColor = [UIColor greenColor];
funView.useRandomColor = NO;
break;
case kRandomColorTab:
funView.useRandomColor = YES;
break;
default:
break;
}
}
- (IBAction)changeShape:(id)sender {
UISegmentedControl *control = sender;
[(BIDQuartzFunView *)self.view setShapeType:[control selectedSegmentIndex]];
if ([control selectedSegmentIndex] == kImageShape)
_colorControl.hidden = YES;
else
_colorControl.hidden = NO;
}
@end
错误:
-[UIView setShapeType:]:无法识别的选择器发送到实例 0x767a0a0 2013-05-14 22:42:15.836 QuartzFun[1014:c07] *由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIView setShapeType:]:无法识别的选择器发送到实例 0x767a0a0'