iphone - 添加到应用程序时 UIAlertView 崩溃

标签 iphone ios xcode uialertview iboutlet

我正在尝试将基本的 UIAlertView 嵌入到我的应用程序中(我正在使用 Storyboard)。但是,当我运行我的应用程序时,它会在应用程序的加载屏幕停顿后转到调试器屏幕。

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

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

我在调试器中找到了这个

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)

最佳答案

问题是您在 Storyboard 中添加了 alert(或指向某个名为 alert 的 View 的指针),但没有将其添加到类代码中。如果您以编程方式显示警报 View ,则可以将其从 Storyboard 中删除。

关于iphone - 添加到应用程序时 UIAlertView 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13665396/

相关文章:

ios - 监听用户在 iOS Switch 上执行的状态更改

ios - 静态链接dylib

objective-c - XCode 不会将我的 iPhone 设置为事件方案

ios - 关于iPhone 4s、5、6、6+之间的触摸坐标

iphone - 是否可以替换已发布的 iPhone 应用程序中的屏幕截图?

ios - 实现 UITextFieldDelegate

objective-c - plist或NSUserDefaults是否更有效地存储少量数据?

iphone - 保留图像数组

ios - 如何使用swift仅在iPhone中以横向显示 Split View

iphone - 如何保护 .ipa?