Ipad simulator not registering all touch events

Discussion in 'iOS Programming' started by cutler121, Jun 27, 2010.

  1. cutler121 macrumors newbie

    Joined:
    Jun 27, 2010
    #1
    I have been converting over an iphone app to be optimized for the ipad display and have run into a strange error. The ipad simulator only registers touch events within the top left 320x480 pixels of the ipad screen. Within this region everything works perfectly outside here no touch events are occurring.

    I am using the following function to capture and display the touch events in an NSlog


    -(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
    UITouch *touch=[touches anyObject];
    CGPoint location = [touch locationInView:self.view];

    int tX =(location.x);
    int tY =(location.y);

    NSLog(@"\t [%d,%d] ",tX,tY);
    }

    The main UIView was defined to be the correct (0,0,768,1024) and within the touch events call the size registers with a bounding box size of 768x955 which seems about right since my main screen has a tabbar.

    Is there somewhere in the new Xcode 3.2/4.0 that the screen size is being set which is limiting the touch events for the ipad to the iphone viewable area?

    Just to forestal other possibilities, the app is targeted to an ipad/iphone universal app, but has the same behavior if targeted to only ipad. Also the app works perfectly in the iphone v4.0 simulator since the viewable area is in that case correct.

    It seems like Xcode must be setting the viewable area in a default somewhere but I don't see anything like that.

    Any help would be greatly appreciated.

    Cheers,

    RC

    PS One other possibly pertinent piece of information, when running the ipad simulator, it correctly shows the ipad screen, but says iphone simulator at the top not ipad.
     
  2. jared_kipe macrumors 68030

    jared_kipe

    Joined:
    Dec 8, 2003
    Location:
    Seattle
    #2
    First thing first, the iPhone simulator is the iPad simulator. The same application running in a different mode.

    Secondly, I'm not sure what you are asking.

    You say that your method is logging values from 0-768 for x and 0-995 for y?

    Is this code running in a UIView subclass that has approximately that bounds? Are you expecting your UIView subclass that is presumably a subView of your (0,0,768,1024) UIView to receive touch events outside its bounds?
     
  3. cutler121 thread starter macrumors newbie

    Joined:
    Jun 27, 2010
    #3
    I didn't say that. I said that touch events are only firing in a 320x480 region on the ipad simulator, outside that no touch events are registering. What I did say was that if you check the bounds size of the region registering the touch events it says that it is 768x955 not the iphone size of 320x480.

    This code is running on a simple UIView as so:

    Code:
    
    - (void)loadView 
    {
    	
    	myView = [[UIView alloc] initWithFrame:CGRectMake(0,0,768,1024)];
    	
    	self.view = myView; 
    }
    
    
    Nothing else funny is going on. So the question is - where is the clipped bounding box for the touch events coming from?
     
  4. PatrickCocoa macrumors 6502a

    Joined:
    Dec 2, 2008
    #4
    I'm with kipe, my guess is that you have some superview UIView (or some othe NSResponder) that your myView is a subview of. That superview is getting the touches and passing them to myView. If that superview has a limited frame, it will ignore everything outside of that frame (and thus not pass those outside touches to myView).

    Perhaps look at your .xib in IB and see if there's an extra view.

    If that's not it, I'm puzzled.
     
  5. digitoxin macrumors newbie

    Joined:
    Mar 30, 2008
    #5
    i had the same problem- only getting touches to respond in the top left 320x240 area. My solution was to change the window frame conditionally in the app delegate:

    Code:
    - (void)applicationDidFinishLaunching:(UIApplication *)application {    
    	
    	if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone){
    		[window setFrame:CGRectMake(0, 0, 320, 240)];
    	}else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    		[window setFrame:CGRectMake(0, 0, 1024, 768)];
    	}
    	
    	[window addSubview:[navigationController view]];
        [window makeKeyAndVisible];
    }
    
    
     

Share This Page