在“段控制”iphone类型的对象上找不到属性

时间:2013-02-26 19:47:17

标签: iphone uisegmentedcontrol

我已经定义了段控制按钮。

@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

1 个答案:

答案 0 :(得分:0)

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