我在我的 .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/