2014-10-20 117 views
2

我見過幾個Q & A在這裏講述了同樣的錯誤,但沒有一個是有幫助的。我仍然遇到同樣的錯誤。我需要改變什麼?這就是我現在所擁有的。
錯誤與此行有關:imageIndex =(imageIndex < 0)? ([圖像計數] -1):
感謝您的幫助!隱式轉換失去了整數精度:'unsigned long'爲'int' - 錯誤

#import "Photogallery.h" 

@interface Photogallery() 


@end 

@implementation Photogallery 
@synthesize imageView; 
int imageIndex = 10; 

- (void)viewDidLoad { 
[super viewDidLoad]; 


} 
- (IBAction)handleSwipe:(UIGestureRecognizer *)sender { 

NSArray *images=[[NSArray alloc]initWithObjects:@"1.jpg",@"2.jpg",@"3.jpg",@"4.jpg",@"5.jpg",@"6.jpg",@"7.jpg",@"8.jpg",@"9.jpg",@"10.jpg", nil]; 

UISwipeGestureRecognizerDirection direction = [(UISwipeGestureRecognizer *)sender direction]; 

switch (direction) { 
    case UISwipeGestureRecognizerDirectionLeft: 
     imageIndex++; 
     break; 
    case UISwipeGestureRecognizerDirectionRight: 
     imageIndex--; 
     break; 

    default: 
     break; 
} 
imageIndex = (imageIndex < 0) ? ([images count] -1): 
imageIndex % [images count]; 
imageView.image = [UIImage imageNamed:[images objectAtIndex:imageIndex]]; 
} 


@end 
+1

這是Objective-C的? (因爲肯定不是C++) – 2014-10-20 16:56:33

+0

對不起,錯誤的標籤。它實際上是objective-c – Max1980 2014-10-20 16:58:00

+1

查看'NSArray count'的文檔。看到它的返回值?使用'imageIndex'變量而不是'int'使用相同的數據類型。 – rmaddy 2014-10-20 17:05:38

回答

相關問題