My app should support both iPhone resolutions (5 and older) using iOS 5 and iOS 6. When I use autolayouts in IB, on iOS 5 app crashes like this: link
So, I am trying to use NSLayoutConstraint in code, but unsuccessfully yet.
Subquestions:
I am adding constraints in viewDidLoad method, but is it correct?
Does updateViewConstraints invoke by framework? I have never seen that it was invoked.
I tried to use examples from apple's docs, but it was without effect to view.
Anybody knows how to do it?
PS: I know it's possible to make it manually by setting frames, but I would like to use NSLayoutConstraints.
UDP: Yes, I know, that's why i use NSLayoutConstraint in code. I can make condition for determining iOS version. The question is about iOS6.
The AutoLayout feature is only compatible with iOS6 and is not supported in iOS5. Thus the crash
If you intend your app to be compatible with iOS5, you can't use AutoLayout in your XIB files.
You can only use older methods, like the AutoResizingMask for example (which is often sufficient for most cases anyway).
Related
I have a project originally targeting iOS7 using a storyboard. I've added a UIStackView to a view controller and get an error that "UIStackView before iOS 9.0". The build fails because of this error.
How can I keep my project as iOS7, while conditionally including newer storyboard elements from iOS9 if device supports them?
I already have conditional code in the project that only runs on iOS8+, but how can I do something similar with a storyboard?
The class UIStackView (and its software) is provided by iOS 9, but is not provided by iOS 8 or 7. When the app tries to instantiate an object from the storyboard in iOS 8, it will fail because it cannot find the class.
The only ways around this:
have different storyboards for different iOS vesions
build a custom class that does the same thing. Then you can use it in the older versions of the iOS. You might find open source libraries that already do this for the class you want.
I am working on the new iphone app and I have to give orientation support in all IOS version(ios 6 and later). can anybody explain what is the best way to handle orientation for all IOS versions.
I searched and found that few of older version delegate methods have been deprecated in the newer version of IOS.
How should I manage of this?
Please provide idea.
Thanks In advance.
In iOS7 & iOS8 you can use auto layout and size classes when you create a new project a
600x600 resolution ViewController is added you have to add constraints on that ViewController then it will run same on all devices
For auto layout you can follow these tutorials
1-[http://www.raywenderlich.com/83276/beginning-adaptive-layout-tutorial][1]
2-[http://www.appcoda.com/introduction-auto-layout/][2]
3-[http://www.brianjcoleman.com/autolayout-xcode6/][3]
Even it will run on iPads too.
thanks
I think those three methods can meet your requirement.
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0);
- (NSUInteger)supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0);
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation NS_AVAILABLE_IOS(6_0);
I've yet to make a Auto-Layoutless Storyboard to running on iOS 5 so my code won't even run on iOS 5 at the moment. However, I do plan on supporting it. At the same time, I also want to incorporate collection views in my app. I will support it on iOS 5 through the use of the publicly available PSTCollectionView on github. I figure, define the collection view IBOutlet as an id and then everything else is simple. Expect one thing...
Defining the delegate and datasource the collection views is a must.
So my question is, upon defining the UICollectionViewDelegate and UICollectionViewDataSource in my view controller
a. will my project even compile for iOS5 devices?
b. if not, how do I add a macro to conditionally define the respect protocols on iOS5 and iOS6?
I am trying to make a simple app from a tutorial that does not have a viewController at all. All the code is in the AppDelegate. I am on xcode 4.2 and I am getting this error:
Applications are expected to have a root view controller at the end of application launch
I'm not sure how to deal with this. There are some blogs out there with fixes but none of them are working for me and I really would like to understand what is going on here. And, how to fix it.
I do have a view that contains some buttons and labels. But I have no "ViewController". The files contained in my project are: AppDelegate.h, AppDelegate.m, and Window.xib only. There is no ViewController.h, ViewController.m
** edit **
I ended up making the app from a 'view based application' instead and just moving all the logic from the app delegate to the view controller. So, I didn't really solve the problem per se. The app works now though. Thanks for the help
It's not possible to have an iOS app that doesn't have a view controller. You can always create a trivial view controller, i.e.,
[[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds].rootViewController =
[[[UIViewController alloc] init] autorelease];
It sounds like you're looking at an old tutorial. UIWindow got a rooViewController property in iOS4. I believe it became required in iOS5 to help keep controller hierarchies and view hierarchies in sync with the addition of custom container controllers (and to fix a corner case where replacing the "root controller" of a UIWindow could stop orientation changes from propagating). There was a WWDC presentation in 2011 that explained this in some detail. I think it was Session 102, Implementing UIViewController Containment.
At then end of the day, there's no good reason not to have a root view controller. Apple wants to be able to assume it's there in their APIs going forward. If the tutorial you're looking at doesn't account for that, it's broken.
While I agree that there may be workarounds, another question to address is: why do you want an app without a view? Even if it's designed to run in the background and present no visual interface, at least make a simple view showing the application name and version, a largeish icon and perhaps a status. This kind of idle screen uses very little system resources, especially when the app is backgrounded, but improves the overall experience of the app.
If you set your deployment target to 4.3 and run on the iPhone 4.3 simulator, you won't get the warning.
To install the iOS 4.3 simulator, go to Xcode > Preferences > Downloads.
As far as I can tell, technically MKPolyline and MKPolygon should not be functional/available when running on an iPad or any other device prior to iOS4. Nevertheless, when I installed 3.2.2, on the device, and updated my build tools with the latest (non-beta) iOS 4.2 SDK, they both work just fine, along with their associated views. What the hell?
I'm not exactly complaining here, given that the alternative would be NVPolyline and it doesn't play well with a huge number of points. I'm just confused. Can someone explain why these classes are available and working on the iPad?
I have not, however, had any success subclassing MKOverlayPathView on 3.2.2, even though MKPolylineView and MKPolygonView both descend from it.
The docs certainly claim that it was first available in 4.0, but I remember the new MapKit overhaul being part of the diff for 3.2. I think the docs just have the timeline of that update wrong.