我對Objective-C非常陌生。我試圖編寫一個方法,我創建一個包含特定大小的圖像文件的UIImageView。將值傳遞給方法參數來創建一個CGRect
這裏是我的方法:
- (void)setImageViewElements:(UIImageView *)imageViewName : (NSString *)imageName : (NSInteger)topX : (NSInteger)topY : (NSInteger)imageWidth : (NSInteger)imageHeight
{
imageViewName = [[UIImageView alloc] initWithFrame:CGRectMake(topX, topY, imageWidth, imageHeight)];
[imageViewName setImage:[UIImage imageNamed:imageName]];
[self.view addSubview:imageView];
}
Xcode中拋出這個警告的方法: 衝突的參數類型實行 'setImageViewElements ::::::': 'CGFloat的*'(又名 '浮動*' )與 'NSInteger的'(又名 'INT')
我想這樣稱呼它:
[self setImageViewElements:myImageView :@"myImage.png" :150 :532 :112 :82];
Xcode中拋出這個警告呼叫: 指針轉換不兼容的整數發送'int'到類型'CGFloat *'(aka'float *')的參數的指針轉換;
我試着改變參數來浮動,CGFloat和int,但我得到相同的錯誤變化。
任何幫助,將不勝感激。
感謝 莫里