【问题标题】:UIAlertView crashes when added to appUIAlertView 添加到应用程序时崩溃
【发布时间】:2012-11-19 20:45:27
【问题描述】:

我正在尝试在我的应用程序中添加一个基本的UIAlertView(我正在使用情节提要)。但是当我运行我的应用程序时,它会在应用程序的加载屏幕停止后进入调试器屏幕。

我的.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] * 终止应用程序到期 未捕获的异常“NSUnknownKeyException”,原因: '[setValue:forUndefinedKey:]: 这个类是 不符合键警报的键值编码。 * 第一次抛出调用栈:(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)

【问题讨论】:

  • 你有没有调用过你的方法showMessage:
  • 你能把你的调试器说的粘贴进去吗
  • 那个方法链接到一个信息按钮,我按照这个教程mobile.tutsplus.com/tutorials/iphone/uialertview
  • 启动应用时,您在屏幕上看到的究竟是什么?黑屏?白屏?
  • 您知道您的应用程序是否要进入您的任何功能吗?

标签: iphone ios xcode uialertview iboutlet


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多