Touch Detection by TOP / BOTTOM

I am starting iOS development, I developed a simple demonstration of multi-touch detection, following this tutorial :

It works fine, but my question is: when I try to start touching from outside the iphone (from TOP or BOTTOM), the touch was not detected, and when I tried to do the same with LEFT / Right, it works. Can someone explain to me why the touch is not detected when I try to drag from above or from below?

+8
ios objective-c touch
source share
5 answers

It does not start from above because the status bar raises contact. Do you know how when you click the status bar, scrollable content jumps to the beginning? This is why the status bar “steals” your touch. If you delete the status bar (you can do this in the Info.plist application), you will get strokes from the top, even with iOS 5 and the extraction center “top”. (A small drop-down pen will appear in the first drop-down list, and if you pull again, the notification center will steal your strokes.)

However, it should start at the bottom if there is no tab bar or other toolbar that also captures strokes.

+8
source share

The status bar will receive a touch event instead of your view. You can hide the status bar:

[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO]; 

Or just set the Status Bar, an initially hidden property in the info.plist file.

In addition, if you use iOS 5, the behavior will be different if the status bar is hidden: you can get the event from your view, but the system will also display a small floating drag panel.

If you do not want to hide the status bar, you can try to set the window level and place the view above the status bar (not sure if this is allowed in the AppStore or not).

+5
source share

I think it is disabled due to the future release of iOS 5, which allows you to display the notification center by touching top-down of your iphone.

How I work on iOS 5, I can’t give you more details, because I can’t check, but I think this is the most likely answer

+2
source share

Using this code in loadView for a UIViewController :

 [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:NO]; CGRect screen = [[UIScreen mainScreen] bounds]; UIView* mainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, screen.size.width, screen.size.height)]; mainView.backgroundColor = [UIColor whiteColor]; self.view = mainView; mainView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin; [mainView release]; 

All touches rise when shifted from the screen in any direction and orientation. Please note that the size of the view always occupies the entire screen.

I believe that others are correct in saying that touch events will appear on the status bar if they are visible. In addition, if the view does not cover the entire screen, it may not receive events. For example, if the y coordinate of the frame is 20, it will not raise the touch when you slide your finger on top.

+1
source share

The previous answers around the status bar are absolutely right, I think.

Remember also that under a recognizing gesture, material is more powerful, but more difficult to program for touch APIs.

The core element is UIEvent, which has touchBegan, touchEnded, touchCancelled, and touchMoved. Check the docs on this, as I am a bit out of memory here ... In any case, you can see that if you even need to open with touchBegan, then starting the gesture outside the touch-sensitive area may not fly. From left to right, it probably works mainly because the area between the screen and the edge is thin enough to touch it, even if you're wrong on the screen. From top to bottom and from bottom to top, however, there are wider areas where you are likely to start outside the scope of the answer.

0
source share

All Articles