English 中文(简体)
未申报的方法
原标题:Undeclared Method Error Objective C IOS

i 奥贝吉斯·塞特是新的,因此,如果这是一个简单的问题,请原谅我。 i 试图从Facebook IOS整合辅导处获得以下代码,但一线有误。

- (void) logoutButtonClicked:(id)sender {
    [facebook logout];

我发现错误。

“使用未申报的识别标志”标志 ButtonClicked. 我知道,这就是说,我正在执行一种没有界定的方法。 因此,我的问题是,下面的法典中正在界定哪些方法?

i have seen a solution here posted but it does not work for me, this error persists. I have tried alternatives to try and fix, but could some one please confirm what this block of code is doing.

My understanding is that, we start of creating a pointer (logoutButton) to UIButton, and we then set the parameters of it. We then use a selector to define an action message (LogoutButtonClicked), for the method UIControlEventTouchInside.

我并不完全理解如何宣布这一方法,因为我认为这里的行文是界定理由方法的:

-(void) logoutButtonClicked:(id)sender {
        [facebook logout];

或者,正在宣布的方法

[logoutButton addTarget:self action:@selector(logoutButtonClicked)
           forControlEvents:UIControlEventTouchUpInside];

// Add the logout button
    UIButton *logoutButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    logoutButton.frame = CGRectMake(40, 40, 200, 40);
    [logoutButton setTitle:@"Log Out" forState:UIControlStateNormal];
    [logoutButton addTarget:self action:@selector(logoutButtonClicked)
           forControlEvents:UIControlEventTouchUpInside];
    [self.viewController.view addSubview:logoutButton];
    // Method that gets called when the logout button is pressed
    - (void) logoutButtonClicked:(id)sender {
        [facebook logout];
    }

我真的会赞赏有人在这样做时提供帮助,他们一直在努力理解这一点。

Melvin

最佳回答

The colon is part of the selectedor s name:

@selector(logoutButtonClicked:)
                             ^

<>0>

@selector(logoutButtonClicked)
问题回答

在另一种方法中,你似乎正在界定一种正确的方法。 你可以这样做。 内容如下:

- (void) logoutButtonClicked:(id)sender {
    [facebook logout];
}

不必在任何其他方法之外出现({<>>>>/code>......>>><>>>>>>。





相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...