0

我已经定义了 segmentControl 按钮。

@property(nonatomic, strong) SegmentControl *option;
SegmentControl *result = [[SegmentControl alloc] initWithFrame:frame items:@[@"Bad", @"Good"]];


result:self.option.selectedSegmentIndex

为什么我会收到此错误:在“segmentControl”类型的对象上找不到属性“selectedSegmentIndex”,

@class SegmentControl;
@protocol SegmentControlDelegate <NSObject>
@optional
- (void)segmentControl:(SegmentControl *)segmentControl didSelectSegment:(UIButton *)segment;

@end

@interface SegmentControl : UIView

@property(nonatomic, assign) BOOL staySelected;
@property(nonatomic, weak) id<SegmentControlDelegate> delegate;

- (id)initWithFrame:(CGRect)frame items:(NSArray *)items;

@end
4

1 回答 1

0

您的 SegmentControl 类需要是 UISegmentControl(不是 UIView)的子类。

于 2013-02-26T22:43:41.690 回答