我在实施分段控制时遇到了麻烦.我相信我已经连接了所有内容,但是当我点击分段控件的任一侧时,该方法没有被调用.
头文件
#import#import "ServiceConnector.h" #import #import #import #import "Global.h" @interface ContactInfo : NSObject @property char group; @property (nonatomic, retain) NSString* firstName; @property (nonatomic, retain) NSString* lastName; @property (nonatomic, retain) NSString* phoneNumber; @property int isSelected; @end @interface Friends : UIViewController { UISegmentedControl *segmentedControl; } @property (nonatomic, retain) IBOutlet UITableView* tblFriends; @property (nonatomic, retain) IBOutlet UIButton* btnAdd; @property (nonatomic, retain) IBOutlet UIButton* btnInvite; @property (nonatomic, retain) IBOutlet UIButton* btnDone; @property (nonatomic, retain) NSMutableArray* contactList; @property (nonatomic, retain) NSMutableArray* contactGroup; @property (nonatomic, retain) NSMutableArray* friendList; @property (nonatomic, retain) NSString* modeStr; @property (nonatomic,retain) IBOutlet UISegmentedControl *segmentedControl; - (IBAction) InviteClicked; - (IBAction) AddClicked; - (IBAction) DoneClicked; - (IBAction)segmentSwitch; - (void) sendSMS:(NSString*) phoneNumber; - (void) sendInviteSMS:(NSMutableArray*) resipients; - (void) getContacts; - (void) groupFromContacts; - (void) groupFromFriends; // table delegates - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath; // service connector delegate - (void)requestReturnedData:(NSData*)data; //message delegate - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result; @end
简化版的实现(方法已被删除)
#import "Friends.h" #import "JSONKit.h" @interface Friends () @end @implementation ContactInfo @end @implementation Friends @synthesize segmentedControl; - (void)viewDidLoad { _friendList = [[NSMutableArray alloc] init]; _contactList = [[NSMutableArray alloc] init]; [self AddClicked]; [super viewDidLoad]; // Do any additional setup after loading the view from its nib. } - (void) dealloc { [segmentedControl release]; [_friendList release]; [_contactList release]; [super dealloc]; } - (IBAction)segmentSwitch { switch (self.segmentedControl.selectedSegmentIndex) { case 0: [self AddClicked]; break; case 1: [self InviteClicked]; break; default: break; } } @end
这是分段控制的连接检查器