ios - 定义警报 View 并使用它

标签 ios iphone uialertview

我在我的 .h 文件 (@property...) 和我的 .m 文件 (@synthesize...) 中定义了一个警报 View ,以便我可以在多种方法中引用它。当我有一个警报 View 分配时,我如何告诉它这是我在 h 和 m 文件中定义的警报 View ?

最佳答案

您需要做的就是将您的警报 View 分配给您设置的属性,就像您进行其他操作一样。就像这里一样,myAlertProperty 是您在界面和实现中设置的属性:

UIAlertView *newAlert = [[UIAlertView alloc] initWithTitle:@"SomeTitle" message:@"SomeMessage" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
self.myAlertProperty = newAlert;
[newAlert show];
[newAlert release];

在这里发布是可以的(也是最好的),因为你正在将它分配给一个属性(假设你在你的@property 中有 retain)。当你处理解雇时,你可以说:

self.myAlertProperty = nil;

关于ios - 定义警报 View 并使用它,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6644362/

相关文章:

ios - react native : Setting flex:1 on a ScrollView contentContainerStyle causes overlapping of components

ios - 多个协议(protocol)的 Swift 类一致性(XCode 7、iOS 9、Swift 2.1)

ios - NSFetchRequest 还获取我的实体类型的子类

iphone - iOS - libical/const char * - 内存使用

ios - 为 UIAlertAction 编写处理程序

iphone - 更改 UIAlertView 的背景颜色?

ios - 如何让用户修改 UITableView 单元格中的文本

ios - 仅在 Swift 4.2 中上传包含多部分表单数据的图像

iOS:UILabel 倒计时卡在其他 UI 操作上

ios - 使用 UIAlert View 让用户输入标题