Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/16.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
Iphone UIAlertView因添加ClickedButtonIndex而崩溃_Iphone_Crash_Uitextfield_Uialertview - Fatal编程技术网

Iphone UIAlertView因添加ClickedButtonIndex而崩溃

Iphone UIAlertView因添加ClickedButtonIndex而崩溃,iphone,crash,uitextfield,uialertview,Iphone,Crash,Uitextfield,Uialertview,我创建了一个类来调用屏幕上的UIAlertview show。我在另一个类中编写UIAlert函数这两个类都不是我的viewController类 我使用这个UIAlert(内部是UITextfield)将文本存储到plist文件中 以下是要调用UIAlert的类: #import "Story.h" @implementation Story ... + (void)stage1 { AlertClass *pointer = [AlertClass new]; [poin

我创建了一个类来调用屏幕上的UIAlertview show。我在另一个类中编写UIAlert函数这两个类都不是我的viewController类

我使用这个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;
}
在将UIAlertViewDelegate添加到.h中并重写“ClickedButtonIndex”方法之前,它工作得非常好。但是,我需要在警报视图中存储UITextfield中的一些数据。我遇到崩溃,不知道它的响应如下

请帮我解决这个问题。谢谢


[crash pic]

对从警报视图返回的文本进行NSLog,以查看这是崩溃还是随后的“self.storyFlow.text=”导致了崩溃。也许self.storyFlow还没有创建(使用alloc/init)

提供图像不是最好的解决方案。。。至少如果是jpeg或png。。。但这是一场争吵!好吧,不管怎样。。。与原始程序集不同的是,如果您复制得到的stacktrace会更好。您是否检查了alertview中的文本是否有效,同时您的self.storyFlow是否已初始化且不为空?我做了NSLog,它没有响应。即使我在“ClickedButtonIndex”中留空,它仍然会崩溃。如果您的AlertClass继承自NSObject,则它无法处理委托alertView“ClickedButtonIndex”方法;您需要将其放在视图控制器中,以便它最终从UIView继承