下面的代碼。UIImagePickerController在使用相機後沒有做任何事情,當我點擊「使用」按鈕
當我在拍照後點擊「使用」按鈕...應用程序變得完全沒有響應。任何想法我做錯了什麼?當在UIViewController視圖上按下按鈕時,將調用「addPlayer:」方法。
感謝
- (IBAction) addPlayers: (id)sender{
// Show ImagePicker
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
// If camera is available use it and display custom overlay view so that user can add as many pics
// as they want without having to go back to parent view
if([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera]) {
imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else {
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// Grab original image
UIImage *photo = [info objectForKey:UIImagePickerControllerOriginalImage];
// Resize photo first to reduce memory consumption
[self.photos addObject:[photo scaleToSize:CGSizeMake(200.0f, 300.0f)]];
// Enable *PLAY* button if photos > 1
if([self.photos count] > 1) btnStartGame.enabled = YES;
// Update player count label
lblPlayerCount.text = [NSString stringWithFormat:@"%d", [self.photos count]];
// Dismiss picker if not using camera
picker dismissModalViewControllerAnimated:YES];
}
它停止在該行的日期? – willcodejavaforfood 2010-04-01 08:41:47
您的「使用」按鈕調用哪種方法? – schaechtele 2010-04-01 13:45:52
「使用」按鈕(來自內置攝像頭控件)調用上面的UIImagePickerControllerDelegate方法。 我能夠得到這個工作,但只有在移動了「[picker dismissModalViewControllerAnimated:YES];」行到同一方法的頂部。然而,似乎仍有點呆滯。 – wgpubs 2010-04-01 17:15:54