2011-12-23 12 views
3

これは私のViewController.hです。とても短くてシンプルなので、これはうまくいくと思いました。Objective-Cクラスでの不完全な実装

// 
// 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であなたのViewController.hに定義されて - (IBAction)Button: (id)sender;方法を実装する必要があり
// 
// 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 

答えて

4

:あなたは.hファイルにこの方法

- (IBAction)Button: (id)sender; 

を追加しているので

- (IBAction)Button: (id)sender{ 
    // Do things here 
} 
+0

ここでプログラムでこれを実装する必要がありますか? –

+0

ViewController.mファイルの '@implementation ViewController'と' @end'の間のどこかにあります。 – kasrak

+0

ありがとう!ほんとうにありがとう。 –

2

をしかし、.mファイルにはありません。理由は

解決方法: hファイルまたは.mファイルの定義されたメソッド。

これで問題は解決します。

お楽しみください!

+0

私はこれについてかなり新しいので、お詫びしますが、 ".hファイルの行や.mファイルの定義されたメソッドのコメント"とはどういう意味ですか? –

+0

"to comment(out)"は、その前に '//'を入れることを意味し、コンパイラによって無視されるコメントに変換されます –

0

同じ警告が表示されましたが、私の場合は、その機能をあるビューから別のビューに移動した後、削除するのを忘れていた使用されていないIBActionでした。

関連する問題