0
我們的應用程序中有一項功能,用戶可以從該攝像頭拍攝多張照片。所有這些照片都添加到NSMuteArray對象,並在用戶點擊保存按鈕後發送到服務器。將多個圖像發送到服務器的問題 - iphone應用程序
目前這個過程不適用於我們,每當用戶點擊保存,應用程序崩潰。我們使用下面的代碼來添加元素NSMuteArray
UIImage *img=[info objectForKey:UIImagePickerControllerOriginalImage];
self.picData=UIImageJPEGRepresentation([[self scaleAndRotateImage:img] fixOrientation], 1.0);
[self.addPhotosBtn setImage:[UIImage imageWithData:self.picData] forState:UIControlStateNormal];
[self.addPhotosBtn setImage:[UIImage imageWithData:self.picData] forState:UIControlStateHighlighted];
[self.addPhotosBtn setImage:[UIImage imageWithData:self.picData] forState:UIControlStateHighlighted];
NSString *ImgData =[[NSString alloc] initWithData:self.picData encoding:NSUTF8StringEncoding];
if (appDelegate.selectedPhotos) {
[self.selectedPhotos addObject:self.picData];
[appDelegate.selectedPhotos addObject:self.picData];
}else{
appDelegate.selectedPhotos=[NSMutableArray arrayWithCapacity:0];
self.selectedPhotos=[NSMutableArray arrayWithCapacity:0];
}
而且,這裏是同時節省我們使用的代碼..
NSDateFormatter *df1=[[NSDateFormatter alloc]init];
[df1 setDateFormat:@"MMMM dd, yyyy"];
NSDate *dd=[df1 dateFromString:self.date.text];
[df1 setDateFormat:@"yyyy-MM-dd"];
NSDictionary *data=[NSDictionary dictionaryWithObjectsAndKeys:
//appDelegate.selectedPhotos,@"photos",
[appDelegate.allcatches objectForKey:@"catches"],@"allcatches",
[appDelegate.selectedPlace objectForKey:@"id"],@"currentplace",
[df1 stringFromDate:dd ],@"currentdate",
[self.description.text isEqualToString:@""] ? @"NULL" : self.description.text,@"description",
self.fbBtn.selected ? @"Y":@"N",@"facebookshare",
self.twBtn.selected ? @"Y":@"N",@"twittershare",
appDelegate.selectedPhotos,@"photos",
nil];
[appDelegate performSelectorInBackground:@selector(uploadPostDataToServer:) withObject:data];
誰能幫我們解決這一問題?
謝謝你的留言...我們只解析一些xml文件... – 2012-04-20 09:59:04
所以你可以發佈上傳進度的源代碼 – CarlJ 2012-04-20 10:00:17