这是我的ViewController.h,它非常简短,所以我觉得这样可行。
//
// ViewController.h
// Blue Bird
//
// Created by Chandler Davis on 12/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Twitter/Twitter.h>
@interface ViewController : UIViewController
- (IBAction)Button: (id)sender;
@end
这是我的ViewController.m,它告诉我“实现不完整”。我做错了什么?
//
// ViewController.m
// Blue Bird
//
// Created by Chandler Davis on 12/23/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//
#import "ViewController.h"
@implementation ViewController
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([TWTweetComposeViewController canSendTweet]) {
TWTweetComposeViewController *tweetComposer = [[TWTweetComposeViewController alloc]
init];
[tweetComposer setInitialText:@"twit"];
[self presentModalViewController:tweetComposer animated:YES];
}
else {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"error" message:@"unable to send tweet" delegate:self cancelButtonTitle:@"ok" otherButtonTitles: nil];
[alertView show];
}
return 0;
}
@end
答案 0 :(得分:4)
您需要实际实现ViewController.m中ViewController.h中定义的- (IBAction)Button: (id)sender;
方法:
- (IBAction)Button: (id)sender{
// Do things here
}
答案 1 :(得分:2)
因为您已添加此方法
- (IBAction)Button: (id)sender;
<。>在.h文件中,但不在.m文件中,这就是为什么
解决方案:您可以在.h文件中注释该行,也可以在.m文件中注释定义的方法。
这将解决问题。
享受!
答案 2 :(得分:0)
我有同样的警告,在我的情况下,在我将该功能从一个视图移动到另一个视图后,我忘记删除了一个未使用的IBAction。