How To control touches on UIWebView? (iphone) - iphone

I want to handle touches on UIWebView same as we can handle touches on UIView.I want to use methods like touches began,touch ended,etc in this app.I have to handle multiple events on different touching events on UIWebView.
In this app I am displaying image in UIWeb View and i have to make image size large and small on double touch and when the user taps on that image the next image should appear and again if the user double taps that image it should navigate to another page and if user swipes then also next image should appear.Thus,i have to handle four events on touching UIWebView.
Please anyone tell me how to do this.I have tried many codes but nothing has helped me.I also tried by making a uiview on uiwebview but only one event happens by this other events does not.
Thanks in Advance.

For what you want to do it sounds as if you shouldn't be using a uiwebview at all. I suggest you reconsider your app's architecture: typically both touch events AND page navigation (both of which you're attempting) are handled in view controllers. Consider implementing a view controller that will handle these events.
Also, don't solicit code and ask for it hand-delivered via email. No one wants to write your code, and you won't learn anything that way anyway.

Related

How to show loading of content from YouTube?

I have a UIViewController with a UIScrollView inside it. This scroll view contains a few strings and images, and more recently it's own UIWebView which contains a YouTube video.
As a first case, assuming the user has Internet access, how should I show the user that the box contains content that is currently loading?
Musings:
I was able to place a UIView on top of this UIWebView (within the scroll view) which contained a UILabel with the text "Loading..." inside it. But I was unable to remove/hide the label based on when the video has fully appeared as I could not get viewDidAppear et al to respond. I also have access to a BOOL which tells me if the user has Internet access or not, so the other side to the question would be to set the same label to explain that they have no web access if that is true. (which would explain the presence of a white box in this scroll view)
I also looked at whether it'd be possible to write a custom responder to fire off when the video thumbnail in the web view had finished loading, but again I couldn't get any of the responder methods to be hit for this to work.
In short, how should I be tackling this problem? Thanks in advance for any advice or assistance.
Set your view controller as the web view's delegate. The UIWebViewDelegate protocol defines two methods, -webViewDidStartLoad: and -webViewDidFinishLoad:, that you should be able to use to track when the page has begun to load and (hopefully) when the thumbnail has appeared.

Drag & sweep with Cocoa on iPhone

I'm about to start a new iPhone app that requires a certain functionality but I'm not sure if it's doable. I'm willing to research but first I just wanted to know if I should at least consider it or not.
I haven't seen this in an app before (which is my main concern, even though I haven't seen too many apps since I don't own an iPhone), but an example would be the iPhone shortcuts panels: you can hold on an app, and then drag it to another panel, sweeping while still dragging it. But this is the core app, is it possible to reproduce something similar within a normal app?
I only need to be sure it can be done before I start digging, I don't need code examples or anything, but if you have some exact resources that you consider helpful, that would be appreciated.
Thanks!
Yes. If you have your custom UIView subclass instance inside a UIScrollView, your view controller just needs to set the UIScrollView to delay content touches and not allow it to cancel touch events.
[scrollView setCanCancelContentTouches:NO];
[scrollView setDelaysContentTouches:YES];
When the user taps and holds in the custom view, the event goes to that custom view, which can process the touch events to drag an item around, but if the user quickly swipes, it scrolls the view.
The "panel" view that you're referring to appears to be a UIPageControl view — although, perhaps, the specific incarnation of this view that Apple uses for the iPhone's home page may be customized.
Instances of generic UIView views that you might touch-and-drag will receive touch events. By overriding methods in the view, these events can be processed and passed to the page control, in order to tell it to "sweep" between pages.
If I wanted to do what you're asking about, that's how I might approach it. It seems doable to me, in any case.
Start with this: Swip from one view to the next view
Try using a UIButton that tracks the time since the state of the button changed to "highlighted". You may need to do this in order to track the dragging and move the button around:
Observing pinch multi-touch gestures in a UITableView
Check to see if the button starts overlapping one side of the screen while being dragged. If s certain amount of time elapses since the button first started overlapping the edge and then manipulate the UIScrollView so that it switches to the next page on the corresponding side of the screen
You may need to use NSTimer to keep track of how long the button is held down, etc.
In any case there's no reason why this couldn't work.
If UIButton doesn't work then perhaps try a custom subclass of UIControl (which tracks the same touch down actions etc.). If that doesn't work then use the window event intercept thing to track everything.

iPhone Drawing in Browser

Can I develop an application on web to draw something on iPhone? I guess not because when I draw in the browser it will be treated as "dragging" but I just want to double check for a solution out there.
Thanks.
Marcelo
I presume you mean to ask if is possible to draw into a UIWebView?
I don't think so. In UIWebView the page display view is embedded in a scroll view and scroll views trap all touches to determine if they can scroll. It's pretty much configured as read only.
You could in theory put a transparent view over the web view to trap the touches then send those to the the actual browser view. I haven't done it but it might possible.

How to create a full-screen modal status display on iPhone?

I'm trying to create a modal status indicator display for an iPhone app, and would like one similar to this one used in Tweetie:
Specifically, this one "shades out" the entire screen, including the toolbar. I don't believe through any normal UIView manipulation, I can extend past the bounds of my window, can I? I believe I've seen a status indicator like this somewhere else on iPhone, possibly when I added an Exchange e-mail account.
I've tried subclassing UIAlertView and overriding its drawRect method. If I don't call [super drawRect:] it doesn't ever display the normal UIAlertView text box, however my drawing rectangle is in an odd size and position.
Anyone have any advice to accomplish this?
Check out MBProgressHUD.
Take a look at the source code to the WordPress application. They have code which you can basically drag and drop into your application to do this.
http://iphone.wordpress.org/development/
I haven't done this myself, but you could layer a UIView at the top of the view hierarchy, and use setHidden to dynamically show or hide it. Since it's at the top of the stack, it should be able to intercept all touch events.

Adding a UIImage on a touch event iPhone

OK i am really struggling with this!
I know had to add an image to the view, i know how to record a touch event. But combining the two is proving to be an issue.
There are lots of tutorials out there on how to move an image with touch events.
But Could anyone suggest how i might complete the following:
Add an image to the view on touch
Add the same image on another touch received by the user.
Manipulate the location of the added images when the user touches a previously added image
Any advice would be highly appreciated
Supposing that you want to simply let the image appear and disappear, you could just implement the UITouch event handling methods in the UIViewController for the view that you want to intercept the touch events in. An example on how to do this can be found in the "iPhone Programming Guide: Event Handling" at:
http://developer.apple.com/IPhone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html#//apple_ref/doc/uid/TP40007072-CH9
Once you have managed to intercept the touch events, you can simply add the UIImageView as a subview of the view you want it to appear in.
I hope that helped a bit.