My button doesn't detect touch events on iPhone (Retina 4-inch) simulator, but works in iPhone (Retina 3.5-inch) simulator - iphone

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.

Related

Storyboard view designed properly with Auto Layout and Trait Variations in Interface Builder of Xcode 8 has wrong size in Simulator and Device

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.

UIImageView is shifting down when viewed on 4 inch iphone

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.

How to design single storyboard file that supports all iphone screen sizes?

I am using storyboard and xcode 4.6 for designing Iphone app. I have very complex viewscontrollers and some of the subviews(like scrollview's and autocomplete tablviews) have generated dynamically. When app build for iphone 4 everything works fine. But, when using Iphone(retina-4 inch) simulator, I noticed that there is space at the top and bottom of the screen and also some of the subviews (like scrollviews and autocomplete tableviews ..) misplaced and covering other subviews in that viewcontroller. I tried to search and found some are suggesting to design/load two xib files based on screen size. I have enabled both autoresize masks and autolayout, but still the problem persists.
How to design a single storyboard file that is feasible for both Iphone-4 and Iphone-5.
Reference:How to develop or migrate apps for iPhone 5 screen resolution?
Update attached screenshot:
Storyboard file
Thanks in advance...
use the button in the picture below to toggle between retina 4 in and 3.5 inch. use the autosizing tool under the size inspector on the top right to get views to position themselves correctly.

Adjust iPhone 5 Screen Size Without Using Autolayout

Enabling Autolayout in .xib or .storyboard and adding a splash screen of 640px by 1136px enables iPhone 5 resolution support for the taller screen.
However, doing so, my app started to display some funny things where I assume autolayout is not a great idea.
I am wondering if there is a way to enable iPhone 5 device support, i.e. fix app's resolution without using Autolayout? Maybe I can set in the code?
If yes, then I will have no need to create 2 storyboards or nibs to support iOS5- and iOS6.
If you weren't using Autolayout before, you won't need to use it for iPhone 5 support.
When you're putting your interface together, you just need to check your bindings, and toggle between the taller phone size, and the regular phone size, as described here:
Xcode Storyboard displaying the new iPhone 5 screen size?
If your screens look fine in both screen sizes then you're done.
If you are doing a lot of coding to show your UI, then you'll have more work to do.
I found a great answer a couple weeks ago (link below). You will copy and paste your older iPhone Storyboard, rename it to reflect the iPhone 5, and press the button that expands the screen size, found on the bottom of the layout grid. Some minor coding adjustments might be needed, but this sample code is used in the AppDelegate to detect which device is running, and hence, which Storyboard to use. You'll just have to duplicate your interfaces, but these GUI changes can be made without code and without AutoLayout (also good to note that AutoLayout removes iOS 5--and lower--compatibility)
xcode 4.5 how to pick storyboards at launch

iphone 5 simulator - Cannot click on bottom of screen?

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.