Setting iOS background/lockscreen image programmatically? - iphone

I'd like to be able to set the lockscreen background image programmatically. I'm aware that this is only possible for jailbroken iOS devices.
Here are some things that I've tried:
Place a LockBackground.png in /private/var/mobile/Library/SpringBoard/. This works but requires a hard respring. notify_post("com.apple.language.changed"); doesn't work for a soft respring.
Use class-dump to dump private methods of UIKit. UIKit in 4.2 used to have a method called + (void)setDesktopImageData:(id)fp8; but it appears to be missing in 4.3 and above.
Is there anything that I'm missing?

I found this in the SpringBoard dump which I think will be of use to you:
In SBWallpaperView.h:
- (void)replaceWallpaperWithImage:(id)image;
And in SBUIController.h:
- (id)wallpaperView;
So you can do something like:
[(SBWallpaperView *)[SBUIController sharedInstance] wallpaperView] replaceWallpaperWithImage:anImage];
That's one way.
The other one I found was to use SBWallpaperView's + (void)noteWallpaperPreferencesChanged;, I'm not that sure about this one, but it seems like if you do what you did in the first thing you tried, and then use this instead of a respring, it might work.

Related

Is there an overview of the text and string drawing system changes in iOS 7?

In iOS 7 some of the most important string drawing and metrics calculation methods were depracated with no obvious alternative given.
The page on NSString UIKit Additions Reference is red like blood. Almost everything deprecated. Xcode throws 300 warnings at me.
I try to find out what was running through Apples mind and what they changed in UIKit text system but where would I start? Did they mention somewhere why all of this is deprecated and how the text system works different now? And how to adapt? How to calculate text bounding box when label can scale the font to fit size? Is TextKit the solution?
I spent 3 hours on Google but I found no useful information on how to solve this problem.
We should document all alternatives here so all developers who run into this depressive deprecation mess find peace of mind quickly.
If you look at the deprecations, most of them deprecate the use of UIFont to use a dictionary of attributes instead.
drawInRect:withFont: (Deprecated in iOS 7.0. Use drawInRect:withAttributes: instead.)
drawInRect:withFont:lineBreakMode: (Deprecated in iOS 7.0. Use drawInRect:withAttributes: instead.)
sizeWithFont:(Deprecated in iOS 7.0. Use sizeWithAttributes: instead.)
etc…
So if you're looking for a place to start, learn how to use dictionaries of attributes to set up fonts. It looks like a lot of deprecations, but you don't actually need to learn that much new stuff.
If you want to update your code to use the new TextKit system, check out the WWDC videos and the TextKit Programming Guide.
If you want to know Apple's reason for deprecating so much, I'd guess that it has to do with how UILabel and UITextView used to be built on web views, now they're built on TextKit.

UICollectionView in ios 5

I just learned about UICollectionView after creating the same functionality in a custom class. So I am thinking about using deleting all that code I wrote and just using UICollectionView.
I know my app gets a lot of installs on iOS 5. And I know a lot non tech savvy friends and family still have it installed.
I googled this and it says I can use some other's guys library(another thing I should have known before writing my custom class). But the answer was not definitive.
So my question is, does Apple include a bridge for iOS 5 or will my app just fail if I use UICollectionView?
I have my target deployment set to 5.0 and it is not giving me any warnings.
Venkat
UICollectionView is iOS6 only. You can include extra code to check for iOS6 and use your custom class on iOS5. But there is no way to use an actual UICollectionView in iOS5.'
Thats what that "other guy's library" does. It has an iOS5 compliant clone of UICollectionView and checks based on the OS which to use.
Maybe you want to try this as an alternative:
https://github.com/steipete/PSTCollectionView

xcode not creating different app Delegate for universal app

i am totally new to iphone and i am trying to create a universal app.
Now I am creating an empty application. According to all tutorials , by checking universal option it should auto create appdelegates for both iphone and ipad.
But all i can see is only one appdelegate . Kindly tell me how can i create both.
Best Regards
Brayden is correct in answering that you almost never need multiple app delegates. All the delegate usually does is handle the moments when the application launches, suspends or terminates. Back in the days when iPhones ran iOS 4.0, and iPads ran iOS 3.2, you might need very different code in the delegate because only iOS 4.0 supported multitasking. Those days are long gone, and your delegate should probably act the same on all devices.
Yes, you sometimes do reach a point where your program must behave differently on iPhone and iPad. Check the idiom at that time and no earlier. Otherwise you're just duplicating code to no purpose.
My most recent app contains almost no special checks for iPhone or iPad. It doesn't even use different XIBs. Instead, my custom views implement layoutSubviews to fill the space available.
That said, once you understand app delegates, maybe you will find a situation where you need them to be different. If you are absolutely certain that your iPhone and iPad behavior will be so wildly divergent, you will need to:
Manually create a new class (preferably inheriting from the existing AppDelegate class)
In your main.m, send the class name of your new delegate to UIApplicationMain depending on the idiom.
See this answer to "Can I create App Delegate file in my project?" to see the changes to main.m.
You really should only be using one AppDelegate for a Universal application. You can use this to share common things that you'll do in there. What exactly do you need multiple AppDelegates for? If you need to do something specific to a device type (i.e. - iPhone or iPad) then you can do a ternary expression like below:
(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? NSLog(#"iPad") : NSLog(#"iPhone");

iphone - The purple location triangle does not go after calling stopUpdatingLocation

I am calling the following code when my app moves to the background -
[m_coreLocationMan stopUpdatingLocation];
However, the purple triangle still stays there. Do I need to do something else as well to make it go?
This is, quite simply, a very regularly occurring OS bug. We noticed this during testing of a large location-aware app. I've personally seen it happen quite often during normal everyday use with different apps.
No. Do you see that on the simulator? Device? What Xcode are you using? Try different simulators and on the device. In some combinations it may not work properly (betas, and some other things that can't be discussed here...)
As I asked there, did you try to also stopMonitoringSignificantLocationChanges ? It worked for me.

How to detect application préference changes

I created a Settings.bundle in my app where the user can change some properties like font size. It works.
But when I leave my App, and I change my setting, I don't know how I can get notified of the change.
For the moment, I create a function call each time a view is loaded that check for app settings.
But I wonder if there is an other and proper way to do this.
You should use your app delegate's application:didFinishLaunchingWithOptions:, or an equivalent location, to check your NSUserDefaults values, or just read them in a UIViewController viewDidLoad method.
While there is no multi-tasking, this is more than adequate. On MacOS X Cocoa we use KVO and bindings to check for changes during the execution of an application; no doubt something similar will work for 4.0 if required.
I finally found the solution. Like you said Paul, for 4.0 sdk version, there is something similar and I found it in "UIApplicationDelegate protocol".
Thank you for helping me. ;)