2011-08-09 4 views
1

私はUIImageViewでプログラムを作成しています。しかし、私はエラーに実行しています:Exc_Arithmetic。しかし、9つの警告やエラー1と、問題iアプリのObj-CプログラムでExc_Arithmeticを実行しました

#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 

プログラムが実行されます。

#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 

マイヘッダー:

は、ここに私の実装です。また、次のボタンを押すとクラッシュします。助けてください!

答えて

1

あなたの "画像"プロパティはNSUIntegerではなくNSArray *である必要があります。

NSArray *images; 

これまでのガイダンスに従うことで、あまりにも多くを置き換えたようです。 =)

+0

私はあなたに感謝することができますどのように? –

+0

DあなたはiPhoneを持っていますか? –

+0

ええ、私は1つ持っています。あなたは私にあなたのアプリをプレゼントしたいですか? =)本当にあなたを助けてくれたら、私の答えを答えとして選ぶと嬉しいです。 –

0

imagesは決して初期化しません。また、countメソッドを呼び出すときは、ではなく、NSArrayである必要があります。

+0

NSArrayのときに画像をどのようなコードで初期化する必要がありますか? –

2

例外は、[画像のカウント]おそらく、あなたはこの式は、分割後の剰余を返し率(%)機能を行う0で除算しようとしたことを示し0である:

imagesIndex = (imagesIndex + 1) % [images count]; 
関連する問題