Xcode应用程序有两个按钮.单击其中任何一个时,都会触发两者的操作.为什么会这样?

Mr.*_*. X 0 twitter xcode objective-c ios

这是我在Apple开发者网站上完成教程后的一个示例Twitter应用程序.但我不知道我做错了什么.

接口:

@interface TWTViewController : UIViewController {
NSString* output;
}
@property (nonatomic, copy) NSString* output;
- (IBAction)doTweet:(id)sender;
- (IBAction)getTimeline:(id)sender;
@property (weak, nonatomic) IBOutlet UILabel *outputLabel;
@property (weak, nonatomic) IBOutlet UIButton *tweetButton;

@end
Run Code Online (Sandbox Code Playgroud)

执行:

@implementation TWTViewController
@synthesize output = _output;
@synthesize outputLabel;
@synthesize tweetButton;

...

- (IBAction)doTweet:(id)sender {
    TWTweetComposeViewController *twitter = [[TWTweetComposeViewController alloc] init];
    [twitter setInitialText:@"It's really that simple!"];
    [twitter addImage:[UIImage imageNamed:@"twitter.png"]];
    [self presentViewController:twitter animated:YES completion:nil];
    twitter.completionHandler = ^(TWTweetComposeViewControllerResult res) {
        if(res == TWTweetComposeViewControllerResultDone) {
            UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Success!" message:@"Your Tweet was posted succesfully." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];

            [alertView show];
        }
        else if(res == TWTweetComposeViewControllerResultCancelled) {
            UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your Tweet was not posted." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
            [alertView show];
        }
        [self dismissModalViewControllerAnimated:YES];
    };
}

- (IBAction)getTimeline:(id)sender {
    ACAccountStore* store = [[ACAccountStore alloc] init];
    ACAccountType* twitterAccountType = [store accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierTwitter];
    [store requestAccessToAccountsWithType:twitterAccountType withCompletionHandler:^(BOOL granted, NSError *error) {
        if(granted) {
            NSArray* twitterAccounts = [store accountsWithAccountType:twitterAccountType];
            if([twitterAccounts count] > 0) {
                ACAccount* account = [twitterAccounts objectAtIndex:0];
                NSMutableDictionary* params = [[NSMutableDictionary alloc] init];
                [params setObject:@"1" forKey:@"include_entities"];
                NSURL* url = [NSURL URLWithString:@"http://api.twitter.com/1/statuses/home_timeline.json"];
                TWRequest* request = [[TWRequest alloc] initWithURL:url parameters:params requestMethod:TWRequestMethodGET];
                [request setAccount:account];
                [request performRequestWithHandler:^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error) {
                    if(error != nil) {
                        self.output = [error localizedDescription];
                        self.outputLabel.text = self.output;
                    }
                    else {
                        NSError* jsonError;
                        NSArray* timeline = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableLeaves error:&jsonError];
                        if(jsonError == nil) {
                            self.output = [timeline componentsJoinedByString:@"|"];
                            self.outputLabel.text = self.output;
                        }
                        else {
                            self.output = [jsonError localizedDescription];
                            self.outputLabel.text = self.output;
                        }
                    }
                }];
            }
        }
    }];
}
@end
Run Code Online (Sandbox Code Playgroud)

这是包含整个项目的ZIP文件:http://www.mediafire.com/?yi4x3d6qn1x4p4r

任何帮助将不胜感激.

Szw*_*edo 5

检查IB中的所有连接.我知道这听起来很愚蠢,但它一直让我感到...