UIAlertView崩溃通过添加clickedButtonAtIndex
问题描述:
我创建一个类来调用UIAlertview显示在我的屏幕上。我在另一个类中编写UIAlert函数。 这两个类都不是我的viewController类。UIAlertView崩溃通过添加clickedButtonAtIndex
我使用这个UIAlert,它是一个UITextfield里面,将文本存储到plist文件中。
这里是调用类UIAlert:
#import "Story.h"
@implementation Story
...
+ (void)stage1
{
AlertClass *pointer = [AlertClass new];
[pointer doAlert];
}
这里是类AlertClass.m文件:
- (void)doAlert
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Message" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert show];
}
//this makes crash!
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
self.storyFlow.text = [alertView textFieldAtIndex:0].text;
}
之前,我在.H添加UIAlertViewDelegate和覆盖的方法 “clickedButtonAtIndex” ,它的效果很好。但是,我需要在警报视图内存储来自UITextfield的一些数据。我崩溃了,不知道它响应的消息如下。
请帮我解决这个问题。谢谢。
答
提供图像不是最好的解决方案...至少如果它是一个JPEG或PNG ......但它是一个TIFF!好吧,无论如何...而不是原始汇编,如果你复制了你得到的堆栈跟踪会更好。 – 2012-09-15 09:01:45
您是否检查过alertview中的文本是否有效,同时您的self.storyFlow被初始化并且不为空? –