2011-12-23 45 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 
// 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

你需要真正落實在ViewController.m在ViewController.h定義的- (IBAction)Button: (id)sender;方法:

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

在程序中我應該實現這個嗎? –

+0

在ViewController.m文件中,'@implementation ViewController'和'@ end'之間的任何位置。 – kasrak

+0

謝謝!對此,我真的非常感激。 –

2

因爲你在.h文件中添加此方法

- (IBAction)Button: (id)sender; 

但不是.m文件這就是爲什麼

解決方案:要麼你可以評論該行。 h文件或.m文件中定義的方法。

這將解決問題。

享受!

+0

我對此相當陌生,所以我表示歉意,但是您的意思是「從.h文件或.m文件中定義的方法中註釋該行」。 –

+0

「to comment(out)」意味着把'//'放在它的前面,這樣它就變成了一個被編譯器忽略的註釋 –

0

我有同樣的警告,在我的情況下,它是一個未使用的IBAction,我忘了刪除後,我從一個視圖移動到另一個視圖。