Re: Using delegates on iOS

[email protected]
Newsgroups gmane.comp.python.pyobjc.devel
Message-ID <CAHc0tyczvU2bfKa+WqQRtby7cO_XvYe=83n2pk3UEcfPRZzzEA@mail.gmail.com>
 Hi.
    I'd like to inform you that I found what the problem was. Basically it
had to do with the fact I didn't start properly the camera viewfinder.
    Let me know if you are interested in more details.

    I will post a working port of my iCam project written in PyObjC, relying
on this module, at http://mobile-revival.110mb.com/ReVival/ (alias
http://go.to/slog) in the following days.
iCam is a cross platform video surveillance application using camera phones
that I worked on for more than 1 year.
    The project transforms a mobile phone in a surveillance camera with
motion detection.
    One can also create a network of such devices connected via Bluetooth or
WiFi, where the master phone transmits via 3G/GSM. The photo/video
information can be uploaded on YouTube, Picasa, etc.
    The phone application can be controlled remotely via Internet.
    This project is deployed and in use for almost 1 year.
  Best regards.


On Sat, Jul 9, 2011 at 12:54 AM, <...> wrote:

>   Hi.
>     When I load UIKit with
>         myUIKit = objc.loadBundle("UIKit", globals(),
> "/System/Library/Frameworks/UIKit.framework")
>       I import a lot of symbols, but a few protocols such as
> UIImagePickerControllerDelegate and UINavigationControllerDelegate are not
> loaded with this occasion (probably because they are not used in any any
> other place).
>
>     Could you please tell me if you have an idea on what goes wrong when
> using UIImagePickerController with UIImagePickerControllerDelegate in the
> code below.
>     The symptom is the following: none of the methods of MyDelegate don't
> get called, although ipc.takePicture() should call them.
>     Documentation on how to use UIImagePickerController at:
>         -
> http://developer.apple.com/library/ios/#documentation/AudioVideo/Conceptual/CameraAndPhotoLib_TopicsForIOS/Articles/TakingPicturesAndMovies.html#//apple_ref/doc/uid/TP40010406
>         -
> http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIImagePickerController_Class/UIImagePickerController/UIImagePickerController.html#//apple_ref/occ/cl/UIImagePickerController
>
> """
> Following
> http://pyobjc.sourceforge.net/documentation/pyobjc-core/wrapping.html:
> "If the framework defines any (informal) protocols you should add
> objc.informal_protocol objects for those protocols to your module. These can
> be defined in a submodule, as long as you arrange for that module to be
> loaded whenever someone imports your package."
> """
> UIImagePickerControllerDelegate =
> objc.informal_protocol("UIImagePickerControllerDelegate", [
>     #- (void)imagePickerController:(UIImagePickerController *)picker
> didFinishPickingMediaWithInfo:(NSDictionary *)info
>     objc.selector(None,
> selector="imagePickerController:didFinishPickingMediaWithInfo:",
> signature="v@:@@"),
>     #- (void)imagePickerControllerDidCancel:(UIImagePickerController
> *)picker
>     objc.selector(None, selector="imagePickerControllerDidCancel:",
> signature="v@:@"),
>     #- (void) imagePickerController:(UIImagePickerController *)picker
> didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary
> *)editingInfo
>     objc.selector(None,
> selector="imagePickerController:didFinishPickingImage:editingInfo:",
> signature="v@:@@@")
>     #objc.selector(None, selector="testMethod", signature="I@:",
> isRequired=1), #isClassMethod=1
> ])
> UINavigationControllerDelegate =
> objc.formal_protocol("UINavigationControllerDelegate",
> (objc.protocolNamed("NSObject"), ), [
>     #The protocol defines methods that the delegate CAN implement (NOT
> mandatory)
>     #- (void)navigationController:(UINavigationController
> *)navigationController didShowViewController:(UIViewController
> *)viewController animated:(BOOL)animated
>     #- (void)navigationController:(UINavigationController
> *)navigationController willShowViewController:(UIViewController
> *)viewController animated:(BOOL)animated
> ])
>
> #class MyDelegate(UINavigationControllerDelegate): #function takes at most
> 1 argument (3 given). ANYHOW BAD BECAUSE I MISTAKED AND USED
> UINavigationControllerDelegate
> class MyDelegate(NSObject, UIImagePickerControllerDelegate):
>     #- (void) imagePickerController:(UIImagePickerController *)picker
> didFinishPickingMediaWithInfo:(NSDictionary *)info
>     @objc.signature("v@:@@")
>     def imagePickerController_didFinishPickingMediaWithInfo_(self, picker,
> info):
>         try:
>             print "Entered
> imagePickerController_didFinishPickingMediaWithInfo_(self, picker = %s, info
> = %s)." % (str(picker), str(info))
>             sys.stdout.flush()
>
>             picker.release()
>         except:
>             traceback.print_exc()
>             sys.stderr.flush()
>
>     #Provide 2.x compliance
>     #- (void) imagePickerController:(UIImagePickerController *)picker
> didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary
> *)editingInfo
>     @objc.signature("v@:@@@")
>     def imagePickerController_didFinishPickingImage_editingInfo_(self,
> picker, image, editingInfo):
>         try:
>             print "Entered
> imagePickerController_didFinishPickingImage_editingInfo_(self, picker = %s,
> image = %s, editingInfo = %s)." % (str(picker), str(image),
> str(editingInfo))
>             sys.stdout.flush()
>
>             #NSDictionary *dict = [NSDictionary dictionaryWithObject:image
> forKey:@"UIImagePickerControllerOriginalImage"];
>
> self.imagePickerController_didFinishPickingMediaWithInfo_(picker, dict)
>         except:
>             traceback.print_exc()
>             sys.stderr.flush()
>
>     #- (void) imagePickerControllerDidCancel:
>     @objc.signature("v@:@")
>     def imagePickerControllerDidCancel_(self, picker):
>         try:
>             print "Entered imagePickerControllerDidCancel_(self, picker =
> %s)." % (str(picker))
>             sys.stdout.flush()
>
>             self.dismissModalViewControllerAnimated_(objc.YES)
>             picker.release()
>         except:
>             traceback.print_exc()
>             sys.stderr.flush()
>
> ipcDelegate = MyDelegate.alloc().init()
>
> ...
> ipc = UIImagePickerController.alloc().init()
> ...
> ipc.takePicture()
>
>
>   Thank you.
>
>

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2

_______________________________________________
Pyobjc-dev mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pyobjc-dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.