iPad touch detected only in 320x480 region - iphone

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

Related

Wrong view size on 3.5 screen

When running my iOS app on a 3.5 inch iPhone Simulator, self.view.frame.size.height is reporting 548px. What is the right way to fix this?
I assume you see this behavior in viewDidLoad, right?
The screen dimensions are not final while in viewDidLoad. You should only rely on the view's frame in viewWillLayoutSubviews method.
it's because you're calling this from viewDidLoad right?
I bet calling the NSLog in this function instead comes back with the correct height;
-(void)viewDidAppear:(BOOL)animated {
NSLog(#"%f", self.view.frame.size.height);
}
You should really be using self.view.bounds instead of self.view.frame
for more information about why and how view this SO:
"Incorrect" frame / window size after re-orientation in iPhone

iPhone 5 UITableView

I am trying to update my App for the iPhone 5's larger screen real estate. I have a tableview that has expanded to take up the full height of the screen by adding the Default-568h#2x.png to my project, but the bottom couple of cells are not responding to touched in the simulator or the actual iPhone 5. Am I missing something? It's like the bottom portion of the screen is not detecting touched (but just in my App not the others).
Any thoughts?
Thanks,
Rob
This is whats working for me
In application didFinishLaunching method I added this -
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
In any other view controller, preferably in - (void)viewDidLoad;
UIScreen *screen = [UIScreen mainScreen];
[self.view setFrame:[screen applicationFrame]];
Yes may be your window frame size in AppDel class or in XIB file of your project's appdel class is not as per iPhone 5 Screen.
And change window frame according 3.5 inch and 4 inch screen of iPhone

2 XIB and 1 viewcontroller but functions don't work in the ipad XIB

I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will.
I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects ( enlarged ;-) ) . I added the callbacks to function correctly with IB.
I can see everything fine and arrive on my new ipad view BUT when I click on one of my buttons... nothing happened like if my callbacks don't work. It is very surprising and actually I have no idea where to look as I compared most of the parameters between my iphone and ipad view and they are identical as far as I can see.
It must be something damn obvious so if one of you had the same issue and it was a very simple answer ... I guess that would be what I missed!
Thanks for your help in advance
Cheers,
geebee
EDIT1: Some code as requested
at start I have that to decide either way:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
examTFVC_NIB=#"ExamTFViewController-iPad";
}
else
{
examTFVC_NIB=#"ExamTFViewController";
}
Then to go to the right view:
ExamTFViewController *examTFViewController = [[ExamTFViewController alloc]
initWithNibName:globals.examTFVC_NIB bundle:nil];
But I have no problem loading the correct XIB. The issue is really the callback functions not being called...
Thanks for the help.
EDIT2:
I also realised that calling the extension of the xib xxx~ipad allows to avoid the example code above. And it works - but still no function can be called.
EDIT3:
IMPORTANT FINDING: if I move my buttons higher and on the left of the screen: they work! So it seems that the functions are called if the event are in the region of an iphone screen although I am on an ipad screen. I guess know it would be more obvious to find the issue! thanks for any help – geebee just now
ANSWER
iPad touch detected only in 320x480 region
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// to correct region size
CGRect rect = [[UIScreen mainScreen] bounds];
[window setFrame:rect];
// now, display your app
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
** OR OTHER SOLUTION **
Check the full screen at launch checkbox - only present in the ipad xib MainWindow
finally solved - with 2 methods - programmatically or via IB - in the edited section of the post.

UIWindow's makeKeyAndVisible not playing nice with ARC

I'm recreating some kind of UIAlertView specific to my app, so I'm subclassing UIWindow to do it. The window gets added to [UIApplication sharedApplication].windows, but is never actually shown. I trimmed it down to this small piece of code:
UIWindow *testWindow = [[UIWindow alloc] initWithFrame:self.view.bounds];
testWindow.backgroundColor = [UIColor blueColor];
[testWindow makeKeyAndVisible];
When I log [UIApplication sharedApplication].windows, I see:
"<UIWindow: 0x83774f0; frame = (0 0; 320 480); opaque = NO; autoresize = RM+BM; layer = <UIWindowLayer: 0x8377660>>",
"<UIWindow: 0x8382630; frame = (0 0; 300 400); layer = <UIWindowLayer: 0xf573e60>>"
And yet that second window with a blue background color is nowehere to be seen.
UPDATE: this seems to be an issue only when ARC is enabled. I created 2 new "single view" projects, one with ARC enabled and the other with ARC disabled. Both are identical and I add the UIWindow code to viewDidAppear: of the main view controller. When I run the apps in the simulator, the blue window only shows up in the ARC-disabled project. It looks like ARC gets rid of my UIWindow too quickly and so it doesn't even have time to show up. Making it __strong didn't help. Still clueless...
It looks like ARC gets rid of my UIWindow too quickly and so it doesn't even have time to show up. Making it __strong didn't help.
Making what __strong? The variable you showed in your question appears to be a local variable, which only exists until the method returns. When the method returns, the variable goes away, so nothing owns the window, so it will then get deallocated.
Assign the window's pointer to a __strong instance variable or a strong property. Then you'll have a longer-lasting ownership keeping the window alive. Set the ivar or property to nil after you dismiss the window.
As a side note, are you sure you want this to be a subclass of UIWindow and not UIView? Even UIAlertView is a view and not a window. If it creates its own window, you may want to do that—have the view create its own window as an implementation detail.
The docs mention that you should use UIScreen to determine the bounds: [[UIScreen mainScreen] bounds]
I'm not sure it's required, but you're not adding a UIView to your window.
I noticed the opaque = NO - try [window setOpaque:NO]; or something similar.
I tested your code and got:
Application windows are expected to have a root view controller at the end of application launch
So basically, use [window setRootViewController:...];. Don't ask me why, this really doesn't seem needed to me.

Only first UIView added view addSubview shows correct orientation

I've got three ViewControllers set up to handle three views. The problem that I'm having is that in the simulator the orientation is LandscapeRight (which is what I want), and the first view shows up correctly in that landscape view, but when I move onto the second and third views, they show up rotated 90 degrees counter-clockwise with the upper-left corner of the view in the lower left corner of the phone's screen. I've been trying to debug this for a few days and the closest that I've gotten to a clue is tracing it the following way:
The following is in my app delegate's applicationDidFinishLaunching:
NSLog(#"1");
[window addSubview:welcomeController.view];
NSLog(#"2");
[window addSubview:goalController.view];
NSLog(#"3");
[window addSubview:planningController.view];
NSLog(#"4");
[window bringSubviewToFront:welcomeController.view];
NSLog(#"5");
Each of my ViewControllers implement something similar to the following (the only change being the controller's name switched out in the string passed to NSLog):
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
NSLog(#"called for WelcomeController");
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
With that, I get the following output on the Console:
a
called for WelcomeController
called for WelcomeController
called for WelcomeController
called for WelcomeController
2
called for GoalController
3
called for PlanningController
4
5
I find it interesting that shouldAutorotateToInterfaceOrientation is called 4 times for the first view that's added, while the other two only get called once. I expect that this is probably because it's got to do some setup at first (and I believe that the simulator starts off in portrait mode, so it's might be calling it while doing the rotation), but I find the correlation a bit suspicious.
I've switched the order around so that the addSubview is called for the goalController first and the welcomeController second. In this case, it's the goalController which displays in the correct landscape orientation (it's normally the welcome controller). This would seem to eliminate my XIB files and the ViewControllers themselves. I'm not sure why the first view where addSubview is called is special. I also tried using insertSubview at index 0 with the same results.
Ran into the same problem, and apparently adding subviews to a UIWindow doesn't work the way I expected it to. I managed to solve the problem after adding a "dummy" UIViewController that is the ONLY subview in the UIWindow. After adding that one, it works perfectly to add multiple subviews to the dummy-controller, all with the correct orientation.
So the only code in the "dummy" controller class is the "shouldAutorotateToInterfaceOrientation" function. This should also match the same function in all the other subviews.
Hope it helps.
I had a similar issue. Not sure why either. But the workaround was to call this on every view after the first one:
[planningController.view setFrame:CGRectMake(0, 0, 480, 300)];
and before -addView. I'm curious if this helps you out. If I am not the only one with this problem and this workaround, then maybe there's a reason.
This is far far far from ideal. But you can hack the second views transform so it is rotated correctly. This works for me because my app is only ever in landscape mode. It may not be ideal if you want to change orientation.
[window addSubview:firstController.view];
[window addSubview:secondController.view];
CGAffineTransform rotate = CGAffineTransformMakeRotation(M_PI/2.0);
[backgroundViewController.view setTransform:rotate];
CGRect contentRect = CGRectMake(0, 0, 1024, 768);
backgroundViewController.view.bounds = contentRect;
[backgroundViewController.view setCenter:CGPointMake(768/2, 1024/2)];
I think I have a solution for this that appears to work. Add a view, and then immediate remove it, repeat for each view, then add all three. Like this:
[window addSubview:welcomeController.view];
[welcomeController.view removeFromSuperview];
[window addSubview:goalController.view];
[goalController.view removeFromSuperview];
[window addSubview:planningController.view];
[planningController.view removeFromSuperview];
[window addSubview:welcomeController.view];
[window addSubview:goalController.view];
[window addSubview:planningController.view];
It seems to work, at least in the simulator.