iPad touch detected only in 320x480 region
I'm upgrading iPhone app and so far everything is going well (managed to resize screen display for most forms). However, I can't solve one problem - the touch is detected only in old, 320x480 region. Any ideas how can I solve that?
Thanks
EDIT: Here are the results when code for fetching superview bounds executes:
CGFloat wdth = self.view.superview.bounds.size.width; NSLog(@"%d", wdth); CGFloat hgth = self.view.superview.bounds.size.height; NSLog(@"%d", hgth);
Result:
2010-04-16 14:25:36.268 xxx[14871:207] 0 2010-04-16 14:25:36.269 xxx[14871:207] 1073741824
Result for (%f):
2010-04-16 14:37:26.048 xxx[15053:207] -1.998374 2010-04-16 14:37:26.049 xxx[15053:207] 0.000000
Result for 开发者_开发知识库(%g):
2010-04-16 14:37:41.113 xxx[15084:207] -1.99837 2010-04-16 14:37:41.115 xxx[15084:207] 9.48221e-38
http://iphonedevelopment.blogspot.com/2010/04/converting-iphone-apps-to-universal.html
In you AppDelegate:
- (void)applicationDidFinishLaunching:(UIApplication *)application { // stupid Apple... CGRect rect = [[UIScreen mainScreen] bounds]; [window setFrame:rect]; // now, display your app [window addSubview:rootController.view]; [window makeKeyAndVisible]; }
In interface builder make sure that mainwindow-iPad "Full screen at launch" window attribute is checked.
I have seen similar behavior when a container view is set too small. The subviews will display fine but touches will not fire because the touches are happening outside of the superview.
The real problem here is that in the file MainWindow-iPad.xib, the Window object gets created with a size of 320 x 480. As ayman2010 mentions, setting the "Full screen at launch" fixes this.
Why would apple create an iPad window so small!!!???
You may also open the (automatically created) MainWindow-iPad.xib in Interface Builder, select File/Create iPad Version, close the MainWindow-iPad.xib and save the unnamed new XIB (which has the correct size) over the old one.
BurninLeo
精彩评论