添加到应用程序时,UIAlertView崩溃 [英] UIAlertView crashes when added to app

查看:113
本文介绍了添加到应用程序时,UIAlertView崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的应用程序中使用基本的 UIAlertView (我正在使用故事板)。但是当我运行我的应用程序时,它会在应用程序的加载屏幕停止后进入调试器屏幕。

I am trying to impliment a basic UIAlertView into my app (I am using storyboard). But when I run my app, it goes to the debugger screen after stalling at the app's loading screen.

我的.h:

    #import <UIKit/UIKit.h>
    @interface MindTripAnim :UIViewController {   
      IBOutlet UIImageView *animation;
    }

    - (IBAction)showMessage:(id)sender;

    @end

和我的.m:

#import "MindTripAnim.h"
@interface MindTripAnim ()
@end

@implementation MindTripAnim

- (void)viewDidLoad {
   animation.animationImages = [NSArray arrayWithObjects:
                             [UIImage imageNamed:@"trips1.png"],
                             [UIImage imageNamed:@"trips2.png"],
                             [UIImage imageNamed:@"trips3.png"],
                             [UIImage imageNamed:@"trips4.png"],
                             [UIImage imageNamed:@"trips5.png"],                          
                             [UIImage imageNamed:@"trips6.png"],nil];
   [animation setAnimationRepeatCount:0];    
   animation.animationDuration = 0.65; 
   [animation startAnimating]; 
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)showMessage:(id)sender
{
    UIAlertView *message = [[UIAlertView alloc] initWithTitle:@"Hello World!" message:@"This is your first UIAlertview message." delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
    [message show];
}
@end

我不确定我做错了什么,或者为什么应用程序在加载屏幕上停滞不前,请帮忙!

I am not sure what I am doing wrong, or why the app keeps stalling at the loading screen, please help!

我在调试器中发现了这个

I found this in the debugger


2012-12-01 19:39:03.428 MindTrip [3327:11303] *终止应用程序
到未捕获的异常'NSUnknownKeyException',原因:
'[setValue :forUndefinedKey:]:这个类是
,不是密钥值编码兼容的密钥Alert。'
*
第一个抛出调用堆栈:(0x1c9a012 0x10d7e7e 0x1d22fb1 0xb84711 0xb05ec8 0xb059b7 0xb30428 0x23c0cc 0x10eb663 0x1c9545a 0x23abcf
0xffe37 0x100418 0x100648 0x100882 0x4fa25 0x4fdbf 0x4ff55 0x58f67
0x1cfcc 0x1dfab 0x2f315 0x3024b 0x21cf8 0x1bf5df9 0x1bf5ad0 0x1c0fbf5
0x1c0f962 0x1c40bb6 0x1c3ff44 0x1c3fe1b 0x1d7da 0x1f65c 0x2a4d 0x2975)
的libc ++ abi.dylib:终止叫抛出异常(lldb)

2012-12-01 19:39:03.428 MindTrip[3327:11303] * Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Alert.' * First throw call stack: (0x1c9a012 0x10d7e7e 0x1d22fb1 0xb84711 0xb05ec8 0xb059b7 0xb30428 0x23c0cc 0x10eb663 0x1c9545a 0x23abcf 0xffe37 0x100418 0x100648 0x100882 0x4fa25 0x4fdbf 0x4ff55 0x58f67 0x1cfcc 0x1dfab 0x2f315 0x3024b 0x21cf8 0x1bf5df9 0x1bf5ad0 0x1c0fbf5 0x1c0f962 0x1c40bb6 0x1c3ff44 0x1c3fe1b 0x1d7da 0x1f65c 0x2a4d 0x2975) libc++abi.dylib: terminate called throwing an exception (lldb)


推荐答案

问题是您已添加 alert (或指向某个名为 alert )在你的故事板中,但同样没有添加到类代码中。如果以编程方式显示警报视图,则可以将其从故事板中删除。

The issue is that you have added alert(or a pointer to some view called alert) in your storyboard but the same is not added to the class code. If you are displaying the alert view programmatically, you can remove it from the storyboard.

这篇关于添加到应用程序时,UIAlertView崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆