2013-12-09 63 views
2

我在執行分段控件時遇到問題。我相信我已經把所有東西都聯繫起來了,但是當我點擊分段控件的任一側時,該方法並沒有被調用。分段控件未調用方法

頭文件

#import <UIKit/UIKit.h> 
#import "ServiceConnector.h" 
#import <MessageUI/MessageUI.h> 
#import <MessageUI/MFMessageComposeViewController.h> 
#import <AddressBook/AddressBook.h> 
#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<UITableViewDataSource, UITableViewDelegate, ServiceConnectorDelegate, MFMessageComposeViewControllerDelegate>{ 
    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 

下面是分段控制

Connection Inspector

+1

段控件沒有觸及裏面但價值改變 – Ilario

+0

這不是一個Xcode的問題,而是一個API的使用。 (我對「但是我使用Xcode」的說法不感興趣,因爲它是無效的。) – 2013-12-09 21:24:34

回答

5

您需要連接檢查將控制掛鉤到「Value」改變「事件,而不是」內心深處「事件。

+0

這工作!它確實讓我把「Touch up Inside事件」連接起來,不知道爲什麼它沒有做任何事情。非常感謝你們,當你學習時,總是有點小事。 – tomjung