I'm trying to update an app to add support for the iPhone 5. Based on other threads I have seen, I have added the Default-568h#2x.png as specified and I have added some new background images to the app that are sized appropriately. The problem is that the bottom portion of my app does not seem to be responding to touch (I have a page control and an info button).
Additionally, when switching screens (using the following code):
[self presentModalViewController:tableNavController animated:YES];
The bottom of the screen blacks out. This black section is basically exactly where I am unable to touch. Screenshot of this issue is below:
Any ideas on why this would be happening? Why I cannot access this bottom section? Note if I run the regular iPhone 4S or iPad simulator this does not happen. I can access the entire section of the screen.
Edit: Could it be a simulator problem? I do not have a physical iPhone 5 yet, so I am unable to test it on a real device.
Edit2: I have tried both enabling and disabling Auto-Layout on both the views and the applications main window. If I add the following log statement to viewDidLoad:
NSLog(#"Window is: %0.0fx%0.0f", window.frame.size.width, window.frame.size.height);
NSLog(#"View is: %0.0fx%0.0f", viewController.view.frame.size.width, viewController.view.frame.size.height);
I receive Window is: 320x480. View is: 320x548. So it looks like it may be a problem with my window. I will continue to investigate.
Figured it out. The main window was not getting resized although the view was. I deleted the window from my xib, created a new one and re-linked it. That solved the issue.
This can be solved by enabling "Full screen at launch" on the window. Deleting and recreating merely enables this.
A simpler solution is to select the window and switch to the Attributes inspector. Change Size to Retina 4 Full Screen.
A simpler solution is to select the window and switch to the
Attributes inspector. Change Size to Retina 4 Full Screen.
Steven's answer is correct, mostly. However now your window is larger than the screen on the 3.5" devices, and the right size on the 4" devices. Basically you will either have to adjust the window size at run-time if you later have anything that references the window, since that will return the 4" window otherwise.
for instance if you used this in your code
[[[UIApplication sharedApplication] delegate] window]
Just be careful with this, that being said it will work for most applications.
Related
I've been working on iOS apps for many years before a longer pause. On my new project I decided to try the new features of the Interface Builder and Storyboards (Swift 3, Xcode 8.2.1). So I've got a working app with precisely defined constraints for all supported devices, following the "regular" and "compact" width/height paradigm. Everything seemed to work and I loved the approach.
I was finalising the first views (and their controllers) for the iPad simulator before I decided to run the app also on an iPhone simulator to check for the layout. It turns out that all works as expected but for ONE view.
This view has the following behaviour:
If in the Storyboard canvas (and even the Assistance Editor, which
looks the same for me, by the way) I selected "view as iPad 9,7" and
run the iPad simulator (of the same screen size), the layout works the way it should.
If in the Storyboard canvas I selected "view as iPhone 5" and
run the iPhone 5 simulator, the layout works the way it should.
If however I select "view as iPhone 5" and run the app on the iPad simulator OR any other false combination, the following happens:
Once the view appears (custom segue, or default push. All the views are inside a navigation controller) it shows the content scaled down/up to the size of the preview size I selected on the Storyboard. Then it animates (scaling from the top left corner) to fill the screen. For instance: If I select "view as iPhone 5" and run on an iPad, the view appears in the left top corner of the iPad simulator having the size of an iPhone 5. Then it scales up to fill the screen having the exact layout I want.
One should add that inside this one view, the layout for all devices looks the same, merely scaled down/up. So it really just comes down to wrong view size.
This all happens ONLY to one of my views, which I all have designed and laid out (constraints) the same way. This happens EVERY TIME, and it happens on the simulator and on real devices.
I was trying various suggestions from the web for the last week and I failed to find any topic (on Stack Overflow) that was able to help me.
I'm lost. I'm glad for any suggestions!
Thank you.
After removing everything from my view step by step and building every single step I found that I had a self.view.layoutIfNeeded() inside my viewDidLoad() which was inside an animation block animating a single subview, but for some reason lead to aforementioned issues. Removing it solved the issue.
I am trying to figure out what settings for the UIImageView below will work with all device sizes.
I'm getting no luck with every combination I've tried.
Here's the .xib:
When I run this on a 4" the image is shifted down much lower from the top label and the buttons stay put.
I have the top label set to Top, tried Aspect Fit/Fill for it as well, didn't change anything. Seems to be an issue with the UIImageView. Also saw someone mention try clip subviews, have that selected, still can't keep it the same size and orientation when going back and forth from 3.5" to 4" iphone on device and simulator.
Hope this helps, in your case you should keep it to the default setting, no change required..
First if turn off the Autolayout setting from XIB.
Now visit my answer here.
When I test my app running in the iPhone 6 simulator everything works as expected. If I however test it in the iPhone 5 or iPhone 5.1 simulators, I can't seem to get button events fired. Im using Xcode 4.5.2, not using storyboards and I have made tests with simple buttons with actions like:
- (IBAction)test:(id)sender {
NSLog(#"YEES");
}
And the actions is connected using drag and drop in the interface builder. I just can't seem to get it fired.. Do you have any idea about what could be the problem?
Update Jan 18:
If I do a "normal" click on a button in the iPhone 5/5.1 simulator nothing happens. If I do a bit "slow" click on a button the button will be "pressed"/selected. If I do a "really slow" click, like holding the button down for 3 seconds I get the button click event! How is this possible??
I found a solution for my case - i added UITapGestureRecognizer to the container UIView, and it intercepts events before UIButtons, and need some time to fail before buttons can handle tap... But it strange that in iOS 6 all works fine
To avoid this we can simply call:
[tapRecognizer setCancelsTouchesInView:NO];
I really suspect this could be the issue of view overlapping.
Please color your views that you are using on the view controllers and check whether any of your view is overlapping your button or not
I had a similar issue with an iPhone 5s simulator. Through trial and error I realized that the button's height in the simulator was 0 or otherwise a small number... The first clue to that was that when I changed its background color - the background did not show in the simulator (on larger simulators, like 6 or 6 plus, it showed as a thin line instead of full height). Then when I added a height constraint, it started accepting click events. That helped me identify the issue, but it was not the solution I was looking for. Initially I laid the button out without size constraints, so it's actual size should have been determined by it's intrinsic size. So instead of the height constraint, I changed the vertical compression resistance of the button to "required". That fixed the issue.
I am testing some old apps on the iPhone 5 simulator. Most of the apps display properly, that is the display centered, maintaining the original iPhone aspect with blank space on the top and bottom.
One of my apps acts differently. It stretches the launch image (an old 2:3 aspect launch image) to the full height top to bottom of the iPhone 5 simulator. Then it snaps the app to the top of the window, as opposed to centering it.
I suspected this had something to do with auto-layout, but as far as I can tell, being new to the concept, it is disabled. As I checked in the file inspector and "use auto layout" is unselected.
Any thoughts? Thanks for reading!
Removing Default-568h#2x.png from the project should solve the problem. It seems like several people have been having a problem with Xcode auto-creating this launch image.
From my experience it looks like when you open a project in XCode 4.5 it automatically adds a flag to each view saying "Autoresize subviews" and by default this is set to true. When I disable this flag for all my views, they no longer stretch. Interestingly though, I don't get the letterboxing in the simulator, instead a get a white band at the bottom.
I ended up manually setting up the views for the iPhone 5 because I could not locate or fix the issue. Setting up the views specifically for the iPhone 5 was relatively easy, but frustrating to not know why it was necessary in this case.
I detected the iPhone 5 using the code below found in this stack overflow answer: How to detect iPhone 5 (widescreen devices)?
#define IS_IPHONE_5 ( [ [ UIScreen mainScreen ] bounds ].size.height > 500)
if (IS_IPHONE_5 ) {
//set up views
}
Remove the Default-568h#2x.png from the project, and also, you must manually remove the app from the simulator before running it again from Xcode. It looks like ios6 saves some kind of a flag for the installed apps that makes it think it should stretch it.
Simply removing the Default-568h#2x.png did not solve my problem.
First I deleted this file, than I drag a 640x1136 image to the "Launch images - Retina (4-inch)" of "iPhone Deployment Info" section in Xcode.
In iOS 7 Sdk if your are not added launch image in your project you need to
Add launch image (640 X 1136 and 640 X 960)into your project, Then go to General Tab and set both launch image (Retina, Retina 4 inch) then remove app from simulator and run again should solve the problem
I'm getting my app ready for the iPhone 5 using the simulator and I've found a weird issue where a couple of my buttons, in one of my views, don't work in the iPhone (Retina 4-inch) simulator, but work fine in the iPhone (Retina 3.5-inch) simulator. The buttons simply don't do anything when they're tapped. Has anyone else experienced this issue?
I having a difficult time figuring out where to start with this one. Any suggestions on where to start?
Thanks so much in advance for all your wisdom!
You need to edit your MainWindow.xib and enable "Full Screen at Launch". For a more detailed explanation, see Apple's docs:
Important: When creating your window in Interface Builder, it is
recommended that you enable the Full Screen at Launch option in the
attributes inspector. If this option is not enabled and your window is
smaller than the screen of the target device, touch events will not be
received by some of your views. This is because windows (like all
views) do not receive touch events outside of their bounds rectangle.
Because views are not clipped to the window’s bounds by default, the
views still appear visible but events do not reach them. Enabling the
Full Screen at Launch option ensures that the window is sized
appropriately for the current screen.
Complete document from Apple
For me, the solution was to set the size ("Simulated Metrics") to "Retina 4 Full Screen" for the MainWindow.xib. I did not need to alter the size of the other screens (they are still set to None). After changing the MainWindow.xib the bottom area becomes clickable again...
The problem was caused by another control overlapping my buttons due to the way the springs and struts were setup. Adjusting the z-order of the buttons fixed the issue. Thanks, all!
There are two solution to this problem :
If you are using MainWindow follow these steps :
a. Select MainWindow.xib.
b. Select Full Screen at Launch from Windows option available in Attributes Inspector.
If your application doesn't contain MainWindow then just add:
self.view.frame = [UIScreen mainScreen].bounds
in ViewDidLoad.
I solved my prob.
view .origin for 3.5 inch and 4 inch screen are different so, when writing common code for both we need to take care at giving CGRectmake(x,y,w,h);
Set temp. diff background color of diff view so you can check if any view is overlapping or not, to fetch event in 4.0 inch.