Programmatically lock iPhone screen in iOS 7 - iphone

I know that we can call GSEventLockDevice (); from the GraphicsServices.framework to lock the screen in iOS 6 and older version, as explained by H2CO3 Here. But unfortunately it's not working in iOS 7.
My Question :
How to lock the iPhone Screen programmatically in iOS 7 ?
Note : I don't want this for Appstore.

Hi it's not possible in iOS7. You need special entitlement so until there will be a jailbreak you are out of luck

Cant you disable all the UIGestureRecognizers for the view? I do it for buttons all the time. It is the 'enabled' property for UIButtons. Im sure you can use something like this to achieve satisfactory results. For the view I think it is userInteractionEnabled property for views. Set your view userInteractionEnabled property to NO with a UISwitch.

Related

GUI elements position in Xcode Storyboard differs from their position in the simulator

I recently worked with Xcode, especially with layout GUI elements. I read a lot of questions here about this, but it did not help me. What I have: ViewController, it lies ImageView, it lay all the other elements, I disable autolayout, screen size and in the simulator and in Xcode - the same (4 inches), but when I run I still see it:
What am I doing wrong, what is there is a way to what looks like a storyboard, and looked in the simulator (and real device) equally?
There might be two issues you are suffering with, please check following points for better understanding.
Check this with iOS 6 simulator. If its working fine then, you need to set ios 6/7 deltas for your subviews. Here is better explanation of it-- Interface Builder: What are the UIView's Layout iOS 6/7 Deltas for?
Check autoresizing masks of your subviews, definitely this is what affecting your views.
Good Luck!
Notice that in your Storyboard view, you have not displayed a status bar and that when running on the simulator, a status bar is shown. This is why all the objects are off placed. To fix this, you can either:
Hide the Status Bar - Call this method in your desired view controller:
- (BOOL)prefersStatusBarHidden {
return YES;
}
Show a simulated metric - Switch on the status bar simulated metric in your Storyboard:

Where are the methods that defines allowed orientations?

I've been working on my app for a while, and it've been out in appStore for a while as well, but I now want to add support for landscape orientation. I've thought I had just unchecked the orientation-icons in the Summary-page of the target to only enable portrait, but when I check them now, nothing happens! A lot of stash has been added, but I can't find any methods that should disable landscape.. What kind of method would that be? I didn't find anything in appDelegate either.. I don't even know where to start looking.. When opening an empty project in xcode, they orient just fine with no methods at all..
In storyboard, when clicking a view and going to inspector, it says Orientation:Inferred. So the problem isn't here.
I using a tabBar, and all the views in the viewControllers are set to Autoresize subviews, as a similar question got answered.
EDIT
When enabling landscape for iPhone using the buttons in the target properties summary, the iPhone is allowed to go landscape, but when enabling it for the iPad, nothing changes..
shouldAutorotate in iOS6 and shouldAutorotateToInterfaceOrientation for previous version.
Note that the orientation is mostly defined by the ViewController.
you can add or remove the supported orientations in info.plist
I solved the issue by making a class for the UITabBarController, and setting shouldAutorotate... to YES. I find it weird though that my iPad storyboard overrode the Summary-page.
EDIT
This is giving me a hard time with everything else.. The device rotates correctly now, but sometimes when launched in landscape, it thinks it's in portrait.. Still trying to figure that out. Even when I ask the app which orientation the devices statusbar is in, it returns portrait even if it really is in landscape..

How to create UI for iPhone 4 in iOS 6 (XCode 4.5)?

I have to create a new app and I am using X Code 4.5 and iOS 6 but when I am creating a UIViewController class with XIB, it is giving me the view of iPhone 5. I understand that but I want to create UI for iPhone 4 as well. How can I add the XIB for iPhone 4?
I dont think so that the XIB file can be changed for iPhone4 and iPhone5. I think you just need to set the UIComponents in the XIB file, taking into account the iPhone4 screen size and set the frame of UIComponents inside the frame i.e 320*480 for iPhone4. Leave the rest of space empty. It will work for iPhone 4. And if you want the application to run for iPhone5 also then just set the property Use AutoLayout on. Dats it..

App icons and images are not displaying in ios5

After updation to ios5, all the tabbar icons and navigation images are not loading into iphone..I don't know wht the reason behing it?
Is there anything special with ios5 or I have to add images anywhere in my app?
in iOS 5 drawRect: is not on some objects e.g. UINavigationBar. You have to conditionally use the new iOS 5 styling methods under these circumstances.
This question and this question might be useful for you.

How to make a universal app

I have a iPhone app I want to convert to an universal app so it can run on iPad. I have tried to find information about how to do it, but I don't find anything that answers my question. I have upgraded the iphone target in xcode to ipad. Then I get a new MainWindow-iPad.xib.
But I have many viewcontrollers and I have made those with code, not xib's. Do I need to have a if-clause in the loadView method that loads different viewcontroller depending on if the user has a iPhone or iPad?
It kind of depends on how you've implemented your loadView methods and how you want your iPad version to differ from your iPhone app.
If you just want your app to use the full screen, you can mostly just check the size of the screen and size your views appropriately and use the autoresizing mask to deal with things when you change orientations.
There are a few gotcha's with this approach, though. For example, modal views can work differently (not taking up the whole screen) and, obviously, the keyboard is a different size.
If you want to use completely different views for your iPad app then, yes, you'll quite possibly have if statements that tell it to use completely different view controllers.
Yes you have to create all xib's for iPad and then you have to write if-clause for Ipad xib to be loaded.