Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-24 Thread Marco Tabini

> I seem to have a loose end though -- when I examine the UIWebView's 
> scrollView property, it initially has a non-nil delegate. I don't know if I 
> should "interpose" as delegate and after taking my snapshot, call the 
> original delegate, or only set myself as a delegate instead of the original. 
> 
> I'm afraid that "posing" as the delegate but still maintaining the original 
> delegate, may imply that I need to implement the WHOLE delegate protocol, 
> just to pass on all delegate calls to the original delegate.
> 
> Any ideas?

Nothing other than trying it out and see what happens… even if you have to 
interpose yourself between the scrollview and its original delegate, 
UIScrollViewDelegate only needs a dozen or so methods anyway.


—Mt.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-23 Thread Motti Shneor
OK Thanks Marco. Thad did the trick!!!

 As I was suspecting, my "Mac" mind was hiding the solution from me. I didn't 
guess that the UIWebView had its own internal UIScrollView to support all the 
navigation gestures (scroll, zoom, rotate, translate etc.) 

On the Mac, usually a view is usually just a view, and if you want to scroll 
it, you'd need to embed it into a scroll-view yourself, and manage the 
interaction.

I tried it now , and it works perfect for my needs. In addition, I get a first 
delegate call when the content is "loaded" from the UIWebView itself. This 
signifies for me the first time the document is already rendered, and where I 
take my first snapshot. I ignore all the scrollView delegate calls prior to 
this call.
I also limit my snapshots to N times a second (in case I receive too frequent 
"scrolling" events) and this further optimize my capturing scheme.

I seem to have a loose end though -- when I examine the UIWebView's scrollView 
property, it initially has a non-nil delegate. I don't know if I should 
"interpose" as delegate and after taking my snapshot, call the original 
delegate, or only set myself as a delegate instead of the original. 

I'm afraid that "posing" as the delegate but still maintaining the original 
delegate, may imply that I need to implement the WHOLE delegate protocol, just 
to pass on all delegate calls to the original delegate.

Any ideas?

Motti Shneor, Mac OS X Software Architect & Team Leader
Spectrum Reflections Ltd.

On 22 באפר 2013, at 16:08, Marco Tabini wrote:

> 
> On 2013-04-22, at 9:04 AM, Motti Shneor  wrote:
> 
>> To be very precise --- I'd like to know how to be notified about ANY UIView 
>> visual change. It somehow seems very obvious to me that such "delegate call" 
>> must exist. Maybe I'm overlooking something very basic here.
> 
> I think I had completely misunderstood what you wanted to do! I think what 
> you want to do is interpose yourself as the delegate of the UIWebView's 
> UIScrollView instance (accessible through the -scrollview property); that 
> lets you track changes in scroll position, zoom level, etc. Is that what you 
> meant?
> 
> 
> —Mt.
> 




___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-23 Thread Motti Shneor
OK Thanks Marco. Thad did the trick!!!

 As I was suspecting, my "Mac" mind was hiding the solution from me. I didn't 
guess that the UIWebView had its own internal UIScrollView to support all the 
navigation gestures (scroll, zoom, rotate, translate etc.) 

On the Mac, usually a view is usually just a view, and if you want to scroll 
it, you'd need to embed it into a scroll-view yourself, and manage the 
interaction.

I tried it now , and it works perfect for my needs. Also, I get a first 
delegate call "loaded" from the UIWebView itself, when the content is first 
rendered completely -- so I take a first snapshot there, and ignore any 
"scrolling" events beforehand. I also limit my snapshots to N times a second 
(in case I receive very frequent "scrolling" events) and this further provides 
the efficiency I need. 

I seem to have a loose end though --- when I examine the UIWebView's scrollView 
property, it initially has a non-nil delegate. I don't know if I should "pose" 
as delegate and after taking my snapshot, call the original delegate, or only 
set myself as a delegate instead of the original. Any ideas?


On 22 באפר 2013, at 16:08, Marco Tabini wrote:

> 
> On 2013-04-22, at 9:04 AM, Motti Shneor  wrote:
> 
>> To be very precise --- I'd like to know how to be notified about ANY UIView 
>> visual change. It somehow seems very obvious to me that such "delegate call" 
>> must exist. Maybe I'm overlooking something very basic here.
> 
> I think I had completely misunderstood what you wanted to do! I think what 
> you want to do is interpose yourself as the delegate of the UIWebView's 
> UIScrollView instance (accessible through the -scrollview property); that 
> lets you track changes in scroll position, zoom level, etc. Is that what you 
> meant?
> 
> 
> —Mt.
> 

Motti Shneor, 
CEO,  suMac LTD.
Software Development for the Macintosh

Home/Office Address: 34 Emek-Ha-Ella St. Appt.1 Modiin, ISRAEL, 71723
Home/Office Tel/Fax: +972-8-9267730
Home eMail: motti.shn...@gmail.com Office eMail: su...@bezeqint.net
Mobile phone: +972-54-3136621
---
ceterum censeo microsoftiem delendam esse
---










___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-22 Thread Sandor Szatmari
I had thought about this too, but was afraid that -drawRect: would be called 
more often than the actual content of the view was being changed.

If you could limit the calls within -drawRect: perhaps by setting a content did 
change flag in the subclass this might reduce the notifications to be 
meaningful.

Like: (written in mail)

-drawRect:(NSRect)rect
{

if ( contentDidChange )
// post notification 

[super drawRect:rect];
}


Sandor Szatmari

On Apr 22, 2013, at 13:30, Jens Alfke  wrote:

> 
> On Apr 22, 2013, at 12:26 AM, Motti Shneor  wrote:
> 
>> I already succeeded in capturing the contents of the view as an image-buffer 
>> (out of the CALAyer's context) and I can (brutally) solve my problem by 
>> setting up a timer that will sample the view's contents N times a second. 
>> However, I'd like to avoid transmitting anything when the view doesn't change
> 
> A quick & naive idea is to subclass UIWebView and override -drawRect: to call 
> the inherited method and then set a timer that will capture the view's pixels 
> a fraction of a second later. (You'd want a timer for coalescing purposes, 
> since there are likely to be multiple calls in a short time interval.)
> 
> The reason I say this is naive is because UIWebView almost certainly has a 
> whole tree of views inside it that do the actual drawing, so the actual 
> -drawRect: calls are probably going to those instead. But you could give this 
> a try and see if you get anything useful.
> 
> —Jens
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/admin.szatmari.net%40gmail.com
> 
> This email sent to admin.szatmari@gmail.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-22 Thread David Duncan
On Apr 22, 2013, at 10:30 AM, Jens Alfke  wrote:

> 
> On Apr 22, 2013, at 12:26 AM, Motti Shneor  wrote:
> 
>> I already succeeded in capturing the contents of the view as an image-buffer 
>> (out of the CALAyer's context) and I can (brutally) solve my problem by 
>> setting up a timer that will sample the view's contents N times a second. 
>> However, I'd like to avoid transmitting anything when the view doesn't change
> 
> A quick & naive idea is to subclass UIWebView and override -drawRect: to call 
> the inherited method and then set a timer that will capture the view's pixels 
> a fraction of a second later. (You'd want a timer for coalescing purposes, 
> since there are likely to be multiple calls in a short time interval.)
> 
> The reason I say this is naive is because UIWebView almost certainly has a 
> whole tree of views inside it that do the actual drawing, so the actual 
> -drawRect: calls are probably going to those instead. But you could give this 
> a try and see if you get anything useful.


Another (likely dealbreaking) downside to this is that its going to call that 
-drawRect: implementation on every frame of a scroll. Since UIKit does some 
minimal work even if your -drawRect: is empty, and because you will then also 
allocate a buffer for the backing store, this is probably not a reasonable 
tradeoff.

To the greater point the likely reason why you haven't gotten any responses 
before is simply because what you request is difficult, if not impossible, 
unless you are acting as the render server itself, which you aren't. Your 
probably better off doing a timed read and sending diffs to the client instead.
--
David Duncan


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com


Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-22 Thread Jens Alfke

On Apr 22, 2013, at 12:26 AM, Motti Shneor  wrote:

> I already succeeded in capturing the contents of the view as an image-buffer 
> (out of the CALAyer's context) and I can (brutally) solve my problem by 
> setting up a timer that will sample the view's contents N times a second. 
> However, I'd like to avoid transmitting anything when the view doesn't change

A quick & naive idea is to subclass UIWebView and override -drawRect: to call 
the inherited method and then set a timer that will capture the view's pixels a 
fraction of a second later. (You'd want a timer for coalescing purposes, since 
there are likely to be multiple calls in a short time interval.)

The reason I say this is naive is because UIWebView almost certainly has a 
whole tree of views inside it that do the actual drawing, so the actual 
-drawRect: calls are probably going to those instead. But you could give this a 
try and see if you get anything useful.

—Jens
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-22 Thread Marco Tabini

On 2013-04-22, at 9:04 AM, Motti Shneor  wrote:

> To be very precise --- I'd like to know how to be notified about ANY UIView 
> visual change. It somehow seems very obvious to me that such "delegate call" 
> must exist. Maybe I'm overlooking something very basic here.

I think I had completely misunderstood what you wanted to do! I think what you 
want to do is interpose yourself as the delegate of the UIWebView's 
UIScrollView instance (accessible through the -scrollview property); that lets 
you track changes in scroll position, zoom level, etc. Is that what you meant?


—Mt.

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-22 Thread Motti Shneor
Thanks Marco,

Actually, we use the UIWebView not to display HTML contents, but because it so 
easily provide multi-document-format display. 

We will probably use it most for displaying PDF documents, Image files, Word 
documents, etc. Anyway, it will display a single, static, local document (not 
from the net). The user will "share" a document, and the document will be both 
displayed, and "shared" to other people through the server.

Moreover, I doubt the efficiency of comparing HTML contents vs. comparing 
images, where I can very easily use the GPU to subtract pixel from pixel, then 
scan for non-zero data.

To be very precise --- I'd like to know how to be notified about ANY UIView 
visual change. It somehow seems very obvious to me that such "delegate call" 
must exist. Maybe I'm overlooking something very basic here.

Was it MY view, I'd "ride" the drawRect: I think. but again, I'm not sure on 
iOS, if you pinch a view to zoom-out, whether drawRect is called or not.

Thanks again!.

On 22 באפר 2013, at 15:29, Marco Tabini  wrote:

> On 2013-04-22, at 3:26 AM, Motti Shneor  wrote:
> 
>> Hello everyone. I asked this several times before, but no one gave any hint 
>> -- I'd like to know if anyone here has any clue, at least where to search 
>> for an answer.
>> 
>> I need to observe the visible contents of a UIWebView dIsplayed in my iOS 
>> application. Each time the visible contents changes, I need to capture the 
>> contents as image, and transmit it to our server. A bit like screen-sharing 
>> on the Mac, but not for the whole screen contents, just a single view.
> 
> If your UIWebView is displaying an HTML document, you could potentially 
> inject some Javascript to watch for DOM changes on the  tag (Google 
> “WebKitMutationObserver”); when a change is detected, your Javascript can 
> force-load a URL with a custom scheme, which you can then trap inside your 
> Objective-C code, where you can capture the view's state.
> 
> There are other ways to achieve this, but this is the only one I can think of 
> that might (a) capture all changes and (b) be in line with Apple's review 
> guidelines. Note, however, that I haven't tried it, so it might not work at 
> all for a number of reasons :-)
> 
> 
> —Mt.
> 

Motti Shneor

Ceterum censeo Microsoftinem delendam esse


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: Third time I ask - please help. How to trace visible change in a UIView (UIWebView)

2013-04-22 Thread Marco Tabini

On 2013-04-22, at 3:26 AM, Motti Shneor  wrote:

> Hello everyone. I asked this several times before, but no one gave any hint 
> -- I'd like to know if anyone here has any clue, at least where to search for 
> an answer.
> 
> I need to observe the visible contents of a UIWebView dIsplayed in my iOS 
> application. Each time the visible contents changes, I need to capture the 
> contents as image, and transmit it to our server. A bit like screen-sharing 
> on the Mac, but not for the whole screen contents, just a single view.

My apologies: another possibility would be to poll at regular intervals, but, 
instead of capturing the entire view, use Javascript to pull its HTML tree, 
compare it with the previous version, and perform a new capture if you detect 
changes. It's still brutal, but, in this case, you'd be comparing two strings, 
which is probably less effort than comparing two images and can be easily 
delegated to a secondary thread.


—Mt.
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com