2013-02-26 46 views
0

我已經定義了segmentControl按鈕。找不到類型爲'segmentControl'的對象的屬性iphone

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


result:self.option.selectedSegmentIndex 

爲什麼我收到此錯誤:屬性 'selectedSegmentIndex' 上鍵入 'segmentControl' 的對象沒有找到,

@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

由於「SegmentControl」類沒有名爲「selectedSegmentIndex」的屬性,也許? – 2013-02-26 19:49:58

+0

是的,我應該使用什麼? – 2013-02-26 20:00:15

+0

你的意思是「你應該使用什麼」? – 2013-02-26 20:00:56

回答

0

你的類SegmentControl必須UISegmentControl(沒有的UIView)的子類。

相關問題