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

2013-04-22 Thread Motti Shneor
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.

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, and I want to 
avoid comparing image-buffers N times a second (frame-differencing) on iOS 
devices, which is battery abuse.

I DO NOT wish to re-transmit when the user rotates his iOS device and the view 
rotates. However I DO want to re-transmit when the user pinches to zoom in and 
out, or scroll through the view's contents. Also, I do not want the whole 
contents transmitted. just the visible part of it. This is why I'm not sure I 
need to ride the drawRect thing. I'm not sure a view must redraw when it 
undergoes visual translation/rotation/scaling etc.

I started looking for the right delegate call, and quite soon got lost. My 
background is Cocoa on MacOS and iOS view/CALayer system still confuses me.

This UIWebView might have subviews I'm not aware of, and it will usually be 
rendering a document file (such as PDF) via a given URL. 

The right way as I see it, is to get notified when the UIWebView decides to 
re-display or redraw its contents after something changes. (either content 
change - redrawing, or some user manipulation zoom, rotate, translate, 
animation).

Can anyone hint on where to start here? 

I'll be grateful for any hint or direction.

Thanks.
Motti Shneor





___

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 su...@bezeqint.net 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

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 mtab...@me.com wrote:

 On 2013-04-22, at 3:26 AM, Motti Shneor su...@bezeqint.net 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 html 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 9:04 AM, Motti Shneor su...@bezeqint.net 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

NSPredicate and NSString with whitespace gives runtime error

2013-04-22 Thread Koen van der Drift
Is there a way I can use an NSPredicate to search an NSString that contains 
whitespaces (a sentence)?  If I use this:

NSPredicate *functionPredicate = [NSPredicate predicateWithFormat: 
@function CONTAINS[cd] %@, searchString];

I keep getting a runtime error:

'NSInvalidArgumentException', reason: 'Unable to parse the format 
string function CONTAINS[cd] %@'


My guess is this happens because the attribute contains whitespace, since I 
have a bunch of similar NSPredicates that searches one-word attributes, and I 
don't get the error.

Thanks,

- Koen.



___

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: NSPredicate and NSString with whitespace gives runtime error

2013-04-22 Thread Ben Gollmer
On Apr 22, 2013, at 10:58 AM, Koen van der Drift koenvanderdr...@gmail.com 
wrote:

 Is there a way I can use an NSPredicate to search an NSString that contains 
 whitespaces (a sentence)?  If I use this:
 
   NSPredicate *functionPredicate = [NSPredicate predicateWithFormat: 
 @function CONTAINS[cd] %@, searchString];
 
 I keep getting a runtime error:
 
   'NSInvalidArgumentException', reason: 'Unable to parse the format 
 string function CONTAINS[cd] %@'
 
 
 My guess is this happens because the attribute contains whitespace, since I 
 have a bunch of similar NSPredicates that searches one-word attributes, and I 
 don't get the error.

The problem may be the use of the word function in your predicate string. See 
this SO question:

http://stackoverflow.com/questions/15801537/unable-to-parse-the-format-string-function-when-using-nspredicates-pr

-- 
Ben

___

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: NSPredicate and NSString with whitespace gives runtime error

2013-04-22 Thread Koen van der Drift

On Apr 22, 2013, at 12:15 PM, Ben Gollmer bgoll...@tcnetworks.com wrote:

 The problem may be the use of the word function in your predicate string.

That's it! I changed the name of the attribute to objectFunction, and it works 
as expected.

Thanks,

- Koen.
___

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: Temporarily disabling autosave

2013-04-22 Thread Steve Mills
The out-of-whackishness that I was seeing was caused by our own portable code 
which stored the current doc dirty state in a global. AUGH!! Yes, a global. *I* 
didn't write it that way. :) Anyhoo, it was preventing the document from ever 
being dirtied again. So to sum up, upon pausing autosave I explicitly tell it 
to autosave if needed via autosaveWithImplicitCancellability, in writeToURL 
return NO and set a userCancelled error if autosave is paused, and in 
hasUnautosavedChanges return NO if autosave is paused. This seems to handle all 
the cases I've tested so far. Thanks for the input, everyone.

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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 su...@bezeqint.net 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 David Duncan
On Apr 22, 2013, at 10:30 AM, Jens Alfke j...@mooseyard.com wrote:

 
 On Apr 22, 2013, at 12:26 AM, Motti Shneor su...@bezeqint.net 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: Temporarily disabling autosave

2013-04-22 Thread Jerry Krinock

On 2013 Apr 22, at 09:43, Steve Mills smi...@makemusic.com wrote:

 So to sum up, upon pausing autosave

which, per previous messages in this thread, I presume you do by sending the 
shared document controller -setAutosavingDelay:0.0.  I'm surprised that this 
has any effect, because this method is Available in OS X v10.4 and later, and 
is apparently part of the the old Tiger autosave mechanism.

But, OK.  It's not marked as deprecated.  Apparently Apple has tweaked this 
method to work for both the old Tiger autosave and the new Lion autosave.  
Surprising.

 I explicitly tell it to autosave if needed via 
 autosaveWithImplicitCancellability, in writeToURL return NO and set a 
 userCancelled error if autosave is paused, and in hasUnautosavedChanges 
 return NO if autosave is paused. This seems to handle all the cases I've 
 tested so far.

You should try each of these three tests while autosave has been *paused*.  

•  Activate another app.
•  Close the document window.
•  Quit the app.

Debug -[NSDocument autosaveWithImplicitCancellability:completionHandler:] 
during this test.  If this message is received, examine the 
implicitlyCancellable parameter and see if it is NO.  Receiving that message 
with parameter NO is the most difficult case you need to handle, or else 
convince yourself that it can't happen.


___

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: NSScrollView in NSTabView autolayout problem

2013-04-22 Thread kwic...@wichry.net
Hello 
My problems persist.
So the NSScrolView as such work perfectly if they are in the active tab view.
However if another tabview is active while window resizing the scrollviews on 
the inactive tabs get crazy and report NSClipVIew constraint with width 0.
Best
K

On 19 Apr 2013, at 08:37, Krzysztof Wicher wrote:

 Thank you Chuck for pointing me to the answer I will try that. I know that 
 NSScrollView is not build with Autolayout in mind but I hoped using it would 
 save several boring layout managment problems arising in my design.
 
 Also, I did send the message last week but as it was my first to this mailing 
 list, I was not sure how long it take so I did not resend.
 
 Thanks again
 
 K
 
 On 18/04/2013 17:37, Chuck Soper wrote:
 This message may be relevant for your issue:
 http://prod.lists.apple.com/archives/cocoa-dev/2013/Feb/msg00426.html
 
 Personally, I don't use auto layout in NSScrollView. I think that
 NSScrollView doesn't support it, but it appears that many people have
 gotten it to work.
 
 Chuck
 P.S. It looks like your message was sent to the list on Saturday, but I
 didn't receive it until this morning.
 
 
 On 4/13/13 1:57 PM, kwic...@wichry.net kwic...@wichry.net wrote:
 
 Hi
 I have an NSTabView with multiple tabs, each containing an NSScrollView.
 In the scrollviews I dynamically place custom views which are sized using
 autolayout and constraints.
 
 Now if I add my custom views to a scrollview in tab1 and resize the
 window with this tab active everything works fine and autolayout does not
 complain.
 
 On the other hand, if I add my custom views to a scrollview in tab1,
 switch to another tab, resize the window, and switch back to tab1
 autolayout breaks with the following exemplar message:
 
 Unable to simultaneously satisfy constraints: (
 NSAutoresizingMaskLayoutConstraint:0x4011d8f60 h=-- v=--
 H:|-(0)-[FlippedDocumentView:0x4011b76e0] (Names:
 '|':NSClipView:0x40120eb80 ), NSLayoutConstraint:0x4012a5c80
 H:|-(10)-[TextViewModuleView:0x401236e80] (Names:
 '|':FlippedDocumentView:0x4011b76e0 ), NSLayoutConstraint:0x4011148e0
 H:[TextViewModuleView:0x401236e80]-(10)-| (Names:
 '|':FlippedDocumentView:0x4011b76e0 ),
 NSAutoresizingMaskLayoutConstraint:0x4011d8f00 h=-- v=--
 H:[FlippedDocumentView:0x4011b76e0]-(0)-| (Names:
 '|':NSClipView:0x40120eb80 ),
 NSAutoresizingMaskLayoutConstraint:0x4011d5e00 h=-- v=--
 H:[NSClipView:0x40120eb80(0)] )
 
 
 What I noticed in the message is this H:[NSClipView:0x40120eb80(0)].
 How come the NSClipView so in fact contentView of the scrollview has
 width = 0?
 My question is, why does the autolayout work fine for the active tab and
 does for inactive?
 
 Thanks
 
 k.
 ___
 
 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/chucks%40veladg.com
 
 This email sent to chu...@veladg.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 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 j...@mooseyard.com wrote:

 
 On Apr 22, 2013, at 12:26 AM, Motti Shneor su...@bezeqint.net 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: Temporarily disabling autosave

2013-04-22 Thread Steve Mills
On Apr 22, 2013, at 17:57:41, Jerry Krinock je...@ieee.org wrote:

 which, per previous messages in this thread, I presume you do by sending the 
 shared document controller -setAutosavingDelay:0.0.  I'm surprised that this 
 has any effect, because this method is Available in OS X v10.4 and later, 
 and is apparently part of the the old Tiger autosave mechanism.

No, that was only something I tried, but it didn't work. The pause mechanism is 
something in our own code - a bool that says it's paused (it's actually an 
integer so it can be incremented/decremented in a nested fashion). I check this 
value in writeToURL and hasUnautosavedChanges.

--
Steve Mills
office: 952-818-3871
home: 952-401-6255
cell: 612-803-6157



___

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