我有下面的代碼,用於在用相機拍照後在iOS應用程序中存儲圖像。圖像需要有一個可識別的名稱,以便以後可以爲每個聯繫人檢索。我怎麼能傳遞給它一個參數或兩個參數,這樣文件名就會變成firstname_lastname.jpg而不是newImage.jpg?Objective-C發送參數到void函數
-(void)saveIMAGE {
NSData *imgView = UIImageJPEGRepresentation(imageView.image, 1.0);
NSArray *path = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docPath = [path objectAtIndex:0];
imgPathString = [docPath stringByAppendingPathComponent:@"newImage.jpg"];
[imgView writeToFile:imgPathString atomically:NO];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Image Saved" message:@"The Image Was Saved." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil]; [alert show];
}
有人能至少說明向下票等等我至少知道我在問我的問題時做錯了什麼? –
使用像:' - (void)saveImage:(NSString *)imageName { ... imgPathString = [docPath stringByAppendingPathComponent:imageName]; ... }' –
謝謝,爲什麼倒票? –