我已经定义了段控制按钮。
@property(nonatomic, strong) SegmentControl *option;
SegmentControl *result = [[SegmentControl alloc] initWithFrame:frame items:@[@"Bad", @"Good"]];
result:self.option.selectedSegmentIndex
为什么我收到此错误:在'segment Control'类型的对象上找不到属性'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
答案 0 :(得分:0)
您的类SegmentControl需要是UISegmentControl的子类(而不是UIView)。