iphone - iPhone的Obj-C程序中的问题Exc_Arithmetic

标签 iphone ios debugging error-handling

我正在用UIImageView编写程序。但是,我遇到了错误:Exc_Arithmetic。

这是我的实现:

#import "SalaatAppViewController.h"

@implementation SalaatAppViewController

@synthesize imageView;
@synthesize pauseButton;
@synthesize playButton;
@synthesize nextButton;

-(IBAction)pushPauseButton {
    [imageView stopAnimating];
}

-(IBAction)pushPlayButton {
    [imageView startAnimating];
}

- (IBAction)pushNextButton {

    imagesIndex = (imagesIndex + 1) % [images count];
    imageView.image = [images objectAtIndex:imagesIndex];

}

- (void)didReceiveMemoryWarning
{
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
    imageView.animationImages = [[NSArray arrayWithObjects:
                                 [UIImage imageNamed:@"1.png"],
                                 [UIImage imageNamed:@"2.png"],
                                 [UIImage imageNamed:@"3.png"],
                                  nil] retain];
    UIImage *image = [UIImage imageNamed: @"2.png"];
    [imageView setImage:image];
    imageView.animationDuration = 1.00;
    imageView.animationRepeatCount = 0;
    [imageView startAnimating];
    imagesIndex = 0;
    imageView.image = [images objectAtIndex:imagesIndex];
    [super viewDidLoad];
    [self.view addSubview:imageView];

}


- (void)viewDidUnload
{
    [super viewDidUnload];
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

-(void) dealloc {
    [imageView release];
    [pauseButton release];
    [playButton release];
    [nextButton release];
    [super dealloc];

}

@end

我的标题:
#import <UIKit/UIKit.h>

@interface SalaatAppViewController : UIViewController {
    UIImageView *imageView;
    UIButton *pauseButton;
    UIButton *playButton;
    UIButton *nextButton;
    NSUInteger images;
    NSUInteger imagesIndex;
}

@property (nonatomic, retain) IBOutlet UIImageView *imageView;
@property (nonatomic, retain) IBOutlet UIButton *pauseButton;
@property (nonatomic, retain) IBOutlet UIButton *playButton;
@property (nonatomic, retain) IBOutlet UIButton *nextButton;


-(IBAction)pushPauseButton;
-(IBAction)pushPlayButton;
-(IBAction)pushNextButton;

@end

该程序运行,但是有9条警告和1条错误。另外,当我按下“下一步”按钮时,它也会崩溃。请帮忙!

最佳答案

Ahmad您的“图像”属性应该不是NSUInteger而是NSArray *。通过以下方式定义它:

NSArray *images;

似乎您按照我之前的指导进行了过多替换。 =)

关于iphone - iPhone的Obj-C程序中的问题Exc_Arithmetic,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6990831/

相关文章:

ios - 在后台运行 HTTP 请求

iOS Storyboard - 一次禁用 Storyboard上的状态栏

python - 构造元组列表的程序

java - 如何以编程方式获取有关 APNS 推送证书的信息?

iphone - 无法将 OCMock header 导入 iOS 项目

iphone - UIImageView setImage 泄漏?

ios - firebase runTransactionBlock

linux - 汇编 MOV 不起作用,调试 Linux 和 INT 代码列表

java - Eclipse - 在代码点执行表达式?

iphone - Flickr SDK 未转换为 ARC