पर फोटो लाइब्रेरी बटन को सक्षम करना क्या किसी को पता है कि कैमरे मोड में UIImagePickerController पर फोटो एल्बम बटन को कैसे सक्षम किया जाए? जैसे कि आईफोन पर कैमरा ऐप छवि और वीडियो लेने के बीच टॉगल कर सकता है और इसमें फोटो लाइब्रेरी देखने के लिए बटन भी है?UIImagePickerController
उत्तर
मुझे डर है कि यह उस आसान तरीके से नहीं किया जा सकता है (बस कुछ जादू सुविधा को सक्षम या अक्षम करें)। कुछ सरल आवश्यकता के लिए, आप कार्यान्वयन के लिए cameraOverlayView और showsCameraControls का उपयोग कर सकते हैं।
आप फोटो/वीडियो मोड के बीच स्विच करना चाहते हैं, मुझे लगता है कि आप इस डेमो देख सकते हैं: http://developer.apple.com/library/ios/#samplecode/AVCam/Introduction/Intro.html
यह निम्नलिखित लाइनों के माध्यम से किया जा सकता है:
- (void) navigationController: (UINavigationController *) navigationController willShowViewController: (UIViewController *) viewController animated: (BOOL) animated {
if (imagePickerController.sourceType == UIImagePickerControllerSourceTypePhotoLibrary) {
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(showCamera:)];
viewController.navigationItem.rightBarButtonItems = [NSArray arrayWithObject:button];
} else {
UIBarButtonItem* button = [[UIBarButtonItem alloc] initWithTitle:@"Library" style:UIBarButtonItemStylePlain target:self action:@selector(showLibrary:)];
viewController.navigationItem.leftBarButtonItems = [NSArray arrayWithObject:button];
viewController.navigationItem.title = @"Take Photo";
viewController.navigationController.navigationBarHidden = NO; // important
}
}
- (void) showCamera: (id) sender {
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
}
- (void) showLibrary: (id) sender {
imagePickerController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
यह कैमरा नियंत्रण नहीं बदलेगा, बल्कि इसके बजाय कैमरा विंडो के शीर्ष भाग में नेविगेशनबार जोड़ें। यह हो सकता है कि आप जो चाहते हैं वह हो या न हो, लेकिन मुझे नहीं लगता कि ओपी के मन में यह क्या था। – DaGaMs
महान समाधान। बस यह जांचना याद रखें कि कैमरा स्रोत वास्तव में उपलब्ध है या नहीं। कुछ ऐसा: यदि ([UIImagePickerController isSourceType उपलब्ध है: UIImagePickerControllerSourceTypeCamera]) { self.picker.sourceType = UIImagePickerControllerSourceTypeCamera; } – EsbenB
यहाँ एक उदाहरण अनुप्रयोग है और बहुत सरल लाइब्रेरी जो आपको फेसबुक लेते हैं या लाइब्रेरी से चुनें, जैसे फेसबुक करता है। https://github.com/fulldecent/FDTake
मैंने ऐप्पल के फोटोपिकर उदाहरण ऐप को इस tweaking किया है। मैंने सभी कैमरा नियंत्रण हटा दिए हैं और अपना खुद का बटन जोड़ा है। क्लिक करने पर, UIImagePickerControllerSourceType UIImagePickerControllerSourceTypePhotoLibrary पर सेट है।
छवि के उठाए जाने के बाद फोटो लाइब्रेरी ("तकनीकी रूप से गलत शब्द हो सकता है) (मेरे लिए तकनीकी रूप से गलत शब्द हो सकता है) के लिए मुश्किल हिस्सा था। मैंने स्रोत प्रकार को UIImagePickerControllerSourceTypeCamera पर सेट करके किया था। यह कैमरा ओवरले दृश्य वापस लाता है।
ViewController.h
#import <UIKit/UIKit.h>
#import <CoreGraphics/CoreGraphics.h>
#import <ImageIO/ImageIO.h>
@interface ViewController : UIViewController <UIImagePickerControllerDelegate> {
//
}
@property (nonatomic, strong) UIImagePickerController *imagePicker;
- (IBAction)uploadNewPhotoTapped:(id)sender;
@end
ViewController.m
#import "ViewController.h"
@interface ViewController()
@end
@implementation ViewController
//Other code
- (IBAction)uploadNewPhotoTapped:(id)sender {
UIImagePickerController *imagePickController=[[UIImagePickerController alloc]init];
//You can use isSourceTypeAvailable to check
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePickController.sourceType=UIImagePickerControllerSourceTypeCamera;
imagePickController.showsCameraControls=YES;
// self.usingPopover = NO;
}
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {//Check PhotoLibrary available or not
imagePickController.sourceType=UIImagePickerControllerSourceTypePhotoLibrary;
imagePickController.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
else if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeSavedPhotosAlbum]) //Check front Camera available or not
imagePickController.sourceType=UIImagePickerControllerSourceTypeSavedPhotosAlbum;
//else //!!!!!!!!!!!exception
imagePickController.delegate=self;
imagePickController.allowsEditing=NO;
[self presentModalViewController:imagePickController animated:YES];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *originalImage=[info objectForKey:UIImagePickerControllerOriginalImage];
//Do whatever with your image
NSData *data = UIImageJPEGRepresentation (
originalImage,
1.0
);
[self dismissModalViewControllerAnimated:YES];
}
// Other code
@end
यहां एक ज़ोंबी जागने के लिए खेद है, लेकिन यदि आपके पास अभी भी आपका कोड है, तो मुझे वास्तव में दिलचस्पी होगी! – bdv
हाय बीडीवी। मैंने वास्तव में अपना कोड खोला और इसे मेरे मूल उत्तर में पोस्ट किया। मुझे बिल्कुल याद नहीं है कि मैंने यह कैसे किया क्योंकि मैंने इस ऐप पर 2 साल में काम नहीं किया है, लेकिन मैंने ऐप्पल के मूल फोटोपिकर ऐप से शुरुआत की। https://developer.apple.com/library/ios/samplecode/PhotoPicker/Introduction/Intro.html – ganime
Swift2 @epsilontik कोड के संस्करण:
//mediaPicker is your UIImagePickerController
func navigationController(navigationController: UINavigationController, willShowViewController viewController: UIViewController, animated: Bool) {
if(mediaPicker.sourceType == UIImagePickerControllerSourceType.PhotoLibrary){
let button = UIBarButtonItem(title: "Take picture", style: UIBarButtonItemStyle.Plain, target: self, action: "showCamera")
viewController.navigationItem.rightBarButtonItem = button
}else{
let button = UIBarButtonItem(title: "Choose picture", style: UIBarButtonItemStyle.Plain, target: self, action: "choosePicture")
viewController.navigationItem.rightBarButtonItem = button
viewController.navigationController?.navigationBarHidden = false
viewController.navigationController?.navigationBar.translucent = true
}
}
func showCamera(){
mediaPicker.sourceType = UIImagePickerControllerSourceType.Camera
}
func choosePicture(){
mediaPicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary
}
- 1. UIImagePickerController
- 2. uiimagepickercontroller
- 3. UIImagePickerController
- 4. UIImagePickerController
- 5. UIImagePickerController
- 6. UIImagePickerController
- 7. UIImagePickerController
- 8. UIImagePickerController
- 9. UIImagePickerController: वीडियो
- 10. UIImagePickerController क्रॉपिंग
- 11. UIImagePickerController प्रतिनिधि चेतावनी
- 12. छोड़ें UIImagePickerController पूर्वावलोकन देखें?
- 13. UIImagePickerController फसल फ्रेम
- 14. UIImagePickerController एकाधिक का चयन
- 15. UIImagePickerController आईपैड समस्याओं
- 16. dismissviewcontrolleranimated पूरा होने uiimagepickercontroller
- 17. UIImagePickerController cameraViewTransform आईओएस 4
- 18. UIImagePickerController मौजूदा UIPopoverController
- 19. UIImagePickerController चुनने वीडियो
- 20. UIImagePickerController पूर्वावलोकन पर कोई ओवरले
- 21. Ipad UIImagePickerController और UIPopoverController त्रुटि
- 22. UIImagePickerController को "सरल" कैसे करें
- 23. UIImagePickerController हमेशा चित्र 640x640 छवि
- 24. आईपैड में UIImagePickerController का उपयोग कैसे करें?
- 25. UIImagePickerController संपादन अनुमति ताले UIImage की 320x320
- 26. UIImagePickerController पर फोटो लाइब्रेरी बटन कैसे जोड़ें?
- 27. एकाधिक छवियाँ (UIImagePickerController या Photos.app शेयर यूआई)
- 28. UIImagePickerController के फ्रेम आकार को कॉन्फ़िगर करना
- 29. UIImagePickerController - अधिकतम वीडियो अवधि सेट करना
- 30. UIImagePickerController मुझे एक काला पूर्वावलोकन देता है
आह ठीक। धन्यवाद!! – MBU