无法将分段控制连接到其IBOutlet

use*_*743 3 iphone objective-c ios xcode4 ios6

我在界面构建器中创建了一个分段控件.

在我的ViewController.h中:

@interface ViewController : UIViewController <MKMapViewDelegate>
@property IBOutlet UISegmentedControl *Segment;
- (IBAction)switchMode:(id)sender;
@end
Run Code Online (Sandbox Code Playgroud)

我能做的是将分段控制与IBAction连接,但我无法将其与IBOutlet连接!

Lit*_*T.V 6

  • 将分段控件添加到nib/Storyboard
  • 将以下代码添加到.h中

@property(nonatomic,retain) IBOutlet UISegmentedControl *Segment;

  • 在storyboard或xib中,确保文件所有者具有与您编写插座的类相同的类名
  • 右键单击segmantControl,出现一个带有出口和操作的窗口
  • 单击并拖动引用插座 并将其放在文件所有者上,会出现一个新的弹出窗口,其中包括用代码编写的插座选择它.

连接已建立