Button events inside UIWebView - iphone

I want to have a on top of uiwebview, which will scroll out of view as I scroll webview downward. The problem is I am not able to raise/handle the button touchupinside event from the viewcontroller. My guess is webview is eating the event. How can I make the button raise events?
One solution is to have a subview containing the button and then have this and the webview inside a scrollview. However this has its own problems and more so because my webpage has expandable sections inside it.
I am currently adding the button as subview inside documentview of the uiwebview, so it scrolls out of view.
Any help in this regard will be appreciated. Thanks.

It's a WebView, so if you're button is actually on the webpage, just use a simple Name attribute on the anchor tag.
If it's not, and it's a UIButton event you are trying to listen to, chances are you wired something up incorrectly with your IBOutlets and IBActions. To send a message to a UIWebView to make it scroll, you can send the stringByEvaluatingJavaScriptFromString: message which will call javascript inside your page. Check out the docs for details.

Related

Scrolling fails if clicking on child

I have a UIScrollView which has a bunch of UIButtons as children.
If I click outside of these buttons, I am able to scroll the UIScrollView. However, if I try to scroll by clicking on one of these buttons, the scrollview doesn't work.
Each button is registered to listen to UIControlEventTouchUpInside.
Any ideas?
If you're touching the button and hoping to scroll, then you should be linking to the UIControlEventTouchDownInside event, not outside!
Additionally, you have to pass the touch event to the underlying UIScrollView to make the scrolling happen. The app is actually trying to do you a favor by letting you click the button and not scrolling the table.
Good luck

Add selector to button on UIScrollView views added dynamically

I have an UIScrollView with n views added dynamically from metadata stored by archiving. I have a PressGesture to make wobble animation (like iOS deleting apps way) and i want to add a button to every subview on the ScrollView for deleting it from the ScrollView and from files.
My problem is for adding the target to the buttons. When they are pressed, the selector (on the UIViewController parent of the UIScrollView) are not called.
How can I get this done? Any other approach is suggested?
Thanks in advance.
When you animate the view it stops responding to user input. And if your button is located inside animated view, it will definitely not call the selector.
The solution would be to wrap your wobbling view into a transparent superview and then place Delete button inside that superview. If you need your button to be also "wobbling" then you need to put an image that represents button inside your wobbling view. And inside wrapper put a transparent Custom button, that will in fact react on user tap.

iPhone4 how to add/animate a UIView to appear under a UIButton?

I have a "side panel" like widget in my app that can be swiped in from the side of the screen. In order to help the users find the panel, I also added a UIButton to do the same thing - scroll the panel on and off screen.
The view comes from a different view controller, otherwise I would've simply created an extra panel in the interface builder and positioned it properly.
My problem is that the side panel gets positioned over the button, so if it is displayed with a button, it can only be dismissed with a gesture.
is it possible to specify at which "depth" I add a UIView when I programmatically add it in code?
This is the snipped that slides the panel in or out within the animation block.
self.audioSystemController.view.frame =CGRectMake(0,20, 120,460);
I need the UIView to be shown below a UIButton, so the button may be used to dismiss the view. I know this is redundant, but I cannot depend on the users to simply discover the side swiping gestures :/
Thank you for your help!
Check out the insertSubview:belowSubview: method of UIView.

How to scroll the outside scrollView not inside scrollView?

I have a scrollView and inside it some scrollViews , and everyone have a webview to show html file, using this method I will zooming every html file , but Now I found that when I scroll the html file it didn't work. I think I scroll the scrollview inside and it autosize the html file , but How to let the scrollview inside not to call the scroll function and when I scroll the html it can call the scroll function outside, and I have disable the scroll property of inside scrollview, but it didn't work, and How to do with it? Thank you very much!
UIScrollView in UIScrollView is a common use. See apple stocks app...
I am trying to send ScrollView Gesture events like pan and zoom from outside the scrollview itself. It doesn't look like apple lets you send to the UIScrollViews handlePan: and handleZoom: methods
A quote from UIScrollView Class reference :-
Important: You should not embed
UIWebView or UITableView objects in
UIScrollView objects. If you do so,
unexpected behavior can result because
touch events for the two objects can
be mixed up and wrongly handled
I would add : "You should not embed UIScrollView objects in UIScrollView "

UIWebView with UISearchBar for searching

I'm displaying a UISearchBar at the top of a UIWebView for entering information that I use to display content in the UIWebView. Is there a way to attach the UISearchBar (or perhaps a UITextField?) to the UIWebView "header" so that when the user scrolls down on the webview the UISearchBar also scrolls out of view and the full window is able to display text?
If this is not possible, how else could I accomplish this while still using the UIWebView for it's inherent text formatting capabilities?
You may try containing the UIWebView and UISearchBar within a UIScrollView. That is, create a controller that has the main view as a UIScrollView and then add in the UISearchBar and UIWebView as subviews. If you want custom behavior when you're scrolling you may have to override the event callbacks for scrolling. I haven't tried this but in theory you could have it so that when you get a scroll down and the UISearchBar is in view, you hide it up to a certain # of pixels until the UISearchBar is hidden. Afterwards you forward the scroll request to the UIWebView so it can deal with things. Basically have a middleman that delegates the scroll events as necessary.