Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/99.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 如何对UIAlert进行子类化?_Ios - Fatal编程技术网

Ios 如何对UIAlert进行子类化?

Ios 如何对UIAlert进行子类化?,ios,Ios,我们正在使用的代码在.h中指定: // // UIAlertView+error.h // iApplication // #import <Foundation/Foundation.h> @interface UIAlertView(error) +(void)error:(NSString*)msg; @end 在为UIAlert选择类时,我遇到了一个难题:它是从UIViewController继承的还是其他东西?上面的代码看起来像UIAlertView上的objec

我们正在使用的代码在.h中指定:

//
//  UIAlertView+error.h
//  iApplication
//
#import <Foundation/Foundation.h>
@interface UIAlertView(error)

+(void)error:(NSString*)msg;

@end

在为UIAlert选择类时,我遇到了一个难题:它是从UIViewController继承的还是其他东西?

上面的代码看起来像UIAlertView上的objective-C类别。它不从UIAlertView继承,而是添加+voiderror:NSString*msg;方法在运行时将该类初始化


我不建议您这样做,如果您想向警报实例添加错误访问器,我会研究新的UIAlertController的子类化

这个问题对我来说没有意义。UIAlertView是一个现有的UIKit类,我们无法选择它继承自什么。而且,它在iOS8中被弃用!它继承了UIView,请看。现在看来,如果某些东西被苹果弃用,它在某种程度上仍然有效。我的应用程序使用了标题为“去交换”的推送序列,但它们仍然有效…我会看看是否可以运行它。顺便说一句,这不是子类化。这是一个类扩展。我可以用UIAlertController系统切换UIAlert吗?