我在用Objective-C的第三版閱讀O'Reilly出版的學習可可過程錯誤:「對‘UIAlertView中’不可見@interface聲明選擇‘initWithTitle’
O'Reilly的網站。 。沒有這種特定圖書的論壇,並搜索出該錯誤不返回任何
在第18頁,我不斷收到以下錯誤:
"No visible @interface for 'UIAlertView' declares the selector 'initWithTitle:message:deluge:cancelButtonTitle:otherButton'"
這裏是我的代碼:
//
// ViewController.m
// HelloCocoa
//
// Created by ME on 1/14/13.
// Copyright (c) 2013 ME. All rights reserved.
//
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (IBAction)showAlert:(id)sender
{
UIAlertView* alert = [[UIAlertView alloc] initWithTitle:@"Hello!"
message:@"Hello, World!"
delegate:nil
cancelButtonTitle:@"Close"
otherButtonTitle:nil];
[alert show];
[_helloButton setTitle:@"I was Clicked!" forState:UIControlStateNormal];
}
@end
//
// ViewController.h
// HelloCocoa
//
// Created by ME on 1/14/13.
// Copyright (c) 2013 Andrew DiNatale. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIView *helloButton;
- (IBAction)showAlert:(id)sender;
@end
什麼原因導致此錯誤?
我不知道它是否是一個錯字,但是您的選擇器讀取'initWithTitle:message:deluge:cancelButtonTitle:otherButton'。洪水? – CodaFi
對不起,這是一個錯字,你可以從代碼中看到我有它不同。我試圖糾正標題,但我不能... – Drewdin