How do I add a touch event to a subview of UIView? - iphone

I'm trying to build by very first app so excuse my ignorance. I love the sample code that Apple put together here called ViewTransitions:
http://developer.apple.com/iphone/library/samplecode/ViewTransitions/Introduction/Intro.html
I want the transition to occur after a user taps the screen once instead of the button like the code does.
Thanks!

Change the inherited class of your xib to be UIControl.

Implement the touch events in your view.

Related

How to create custom iOS View

I'm looking to create a custom UIView (like the above realtor.com app) so when the user selects send email or something to that effect a little view pops up confirming the action then disappears. Any direction, tutorials or code snippets would be greatly appreciated. Also what is the correct terminology of what I'm looking to do? Please excuse my ignorance on this subject.
Use Custom UIActivityIndicator that you can found in this link
https://github.com/jdg/MBProgressHUD
This is not Apple specific controls. You can create them. The pop up shown in first image is very easy to make. You'll have to use 3 controls to make it.
1) Background UIImageView with the image.
2) UIActivityIndicatory
3) UILabel with whatever message you want to display.
MBProgressHUD is an iOS drop-in class that displays a translucent HUD with an indicator and/or labels while work is being done in a background thread. The HUD is meant as a replacement for the undocumented, private UIKit UIProgressHUD with some additional features.......
There is more option that useful for your work, For mor information go to above Link
Why not use something that's already available? Take a look at ZAActivityBar (https://github.com/zacaltman/ZAActivityBar) which handles creating 'toast'-like popups.
It's a part of CocoaPods, so it's very easy to install.
yes you can customize,go throgh below steps
1)add selector to your sendEmail button
2)in that selector function create one view, and add your emailSent image as a background
3)now add this view to mainView simply by addSubView
or for nice than above
1)add selector to your sendEmail button
2)in that selector function create one UIControl of size 480 x320, and add a imageView to it & if you want also can add one ok button
3)now add selector for UIControl, in that selector function just remove your view from sperView
4)now add UIcontrol to mainView
Here you can find the source code for showing toast like android
https://github.com/scalessec/Toast

UIView Receive Touch And Slide Action

I am a newbee in iOS development; and i want to develop a simple application.
In my application there is a view that is a member of xib. I want to receive user's touch and slide actions on my view to run some sliding animations.
I found some codes about this animation but i couldn't find how can i receive sliding action in UIView.
At least, i wanna explain why i used view. This view will contains two or more labes. So i couldn't be sure to choose Rect Button or UIView.
I hope you can help me.
You need to look at Gesture Recognizers. There are tonnes of resources and examples online. For example, here's an example on how to use swipe (slide) gesture recognizers.

UITableViewCell Swipe for Drawer

This is really more of a curiosity than a hard coding question.
Both Facebook and Twitter both have a feature where swiping a UITableViewCell animates the cell off the side to reveal a drawer with more controls underneath. How is something like that accomplished?
Here is a great open-source method for doing exactly this, based on the behavior of the Twitter app:
https://github.com/thermogl/TISwipeableTableView
This is a problem I have tried a couple of different solutions to. I really liked the behavior of Mailbox (mailboxapp.com). So I set out to achieve this. In the end I ended up with what I believe is a very simple solution: use a UIScrollView inside your cell. I have blog post that discusses and a sample app that demonstrates this behavior.
2 ways to detect swipt action
look at the willTransitionToState: method of UITableViewCell.
this method will be invoked when you swipe at the cell.
Custom swipe detection in a TableViewCell
and then you can change your cell view easily.
You could just implement -tableView:willBeginEditingRowAtIndexPath: in your table view delegate.
From the doc,
This method is called when the user swipes horizontally across a row; ... This method gives the delegate an opportunity to adjust the application's user interface to editing mode.
As a UITableViewCell is just a UIView, you can use this fact to basically do anything you like with it.
To solve your problem, I'd attach a UISwipeGestureRecognizer to detect the swipe and then animate the view to a different state.
For example, you could create a custom cell that has it's content view laying above the "actions view". Whenever there is a swipe, you use a UIView animation to move the content view aside and show the action view with a couple of buttons instead. In a custom UITableViewCell you could add a delegate protocol to have the pressed action and the cell being sent to the delegate, i.e. your controller. There you'd trigger what ever there is to trigger and then transition the cell out of the state.

Touch events not working on UIViews inside UIScrollView

I have a series of UIViews inside a UIScrollView, and the UIViewControllers for those views are not receiving the touch events. If I take the views out of the scroll view then it works.
I have enabled userInteraction on the views but it's still not working!
This must be possible and I'd be really grateful if someone could point me in the right direction!
Thanks,
Mike
Do the views have their own touch handlers, or are you relying on the viewcontroller to get the touches? Depending on how you have set things up, the views may be handling the touches without passing through to the view controller.
I have overcome this issue by overriding the loadView method of the view controller, and setting the view's instance variable to a simple UIView subclass which passes on the touches.
Check what you are returning in scrollview delegate method view for scrollin in scroll view.
As mahboudz mentioned - check if you have any custom handler for touch event. If not, please have one. Its far more relief to do whatever you want to do with your view. Check out Apples sample app from scrollViewSuite. They have tapDetectingImageView delegate. I used the same in my app it worked great! Hope this helps!
You may find this post useful. It's an example of a pretty clean way of intercepting events.
Have touch handlers for view for which you want to receive touch events and that will work.

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.