我想讓我的第一個iOS應用程序,和教程要求我使用UIAlertView。 XCode告訴我這已被棄用,我應該使用UIAlertController。我用UIAlertController替換了UIAlertView的實例,並且仍然遇到問題:它說:「沒有可見的@interface for'UIAlertController'聲明選擇器'initWithTitle:message:delegate:cancelButtonTitle:otherButtonTitles:' 我將不勝感激任何幫助我的代碼如下:IOS/Objective C開發新手; UIAlertView /控制器問題
//
// ViewController.m
// cv
//
// Created by Frank Michael Tocci on 6/17/16.
// Copyright © 2016 Frank Tocci. 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.
UIAlertController * alert = [[UIAlertController alloc] initWithTitle:@"Hello!" message:@"Welcome to OpenCV" delegate:self cancelButtonTitle:@"Continue" otherButtonTitles:nil];
[alert show];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
'UIAlertView'和'UIAlertController'是兩個不同的東西。另外,不建議使用'UIAlertView'。 – liamnichols
請閱讀UIalertController的文檔以及如何使用它! –