I use the privite API to change wallpapper. It works well in iOS 9.3, but in iOS 10 nothing happend, no crash.
Class class = NSClassFromString(#"PLStaticWallpaperImageViewController");
_wallPaper = [[class alloc] performSelector:NSSelectorFromString(#"initWithUIImage:") withObject:_image];
int wallpaperMode = 0;
[_wallPaper setValue:#(wallpaperMode) forKey:#"wallpaperMode"];
[_wallPaper setValue:#(YES) forKeyPath:#"allowsEditing"];
[_wallPaper setValue:#(YES) forKeyPath:#"saveWallpaperData"]; //
NSString *selector = #"setImageAsLockScreenClicked:";
[_wallPaper performSelector:NSSelectorFromString(selector) withObject:nil];
Does anyone know how to do this in iOS 10?
Related
Because my build machine is still using the Xcode 12.5 , So the UITabBar's scrollEdgeAppearance(which will not exist in the Xcode 12.5's SDK) will make the build fail even i'am using the #available to check .
if (#available(iOS 15.0, *)) {
UINavigationBarAppearance* navBarAppearance = [UINavigationBarAppearance new];
navBarAppearance.backgroundColor = [UIColor colorNamed:#"navbar_bg"];
[UINavigationBar appearance].standardAppearance = navBarAppearance;
[UINavigationBar appearance].scrollEdgeAppearance = navBarAppearance;
UITabBarAppearance* tabBarAppearance = [UITabBarAppearance new];
tabBarAppearance.backgroundColor = [UIColor colorNamed:#"second_bg"];
[UITabBar appearance].standardAppearance = tabBarAppearance;
[UITabBar appearance].scrollEdgeAppearance = tabBarAppearance;
[UITableView appearance].sectionHeaderTopPadding = 0;
}
So is it possible to do this kind of SDK checking in code ,when the build SDK is not the newest SDK , these code will not be involved to build? like this
if (BuilDSDK >= someversion)
{
[UITabBar appearance].scrollEdgeAppearance = tabBarAppearance;
}
#available is a runtime availability check, not really usable for compile-time stuff in this situation.
In Objective-C, you can wrap the code part applied on iOS 15 SDK into another, macro condition:
#ifdef __IPHONE_15_0
if (#available(iOS 15.0, *)) {
...
} else {
#endif
// possible legacy branch code
#ifdef __IPHONE_15_0
}
#endif
__IPHONE_15_0 is defined starting with iOS 15 SDK, thus being omitted when building in Xcode 12/iOS 14 SDK. 👍
Another similar solution for Swift classes can be found here: https://stackoverflow.com/a/69583441/1195661:
#if swift(>=5.5) // Only run on Xcode version >= 13 (Swift 5.5 was shipped first with Xcode 13).
if #available(iOS 15.0, *) {
UITabBar.appearance().scrollEdgeAppearance = tabBarAppearance
}
#endif
Below is a snippet showing adding a subcaption to a previously created MSMessage. Upon running in the simulator, the string prefixed with $ does not translate to the contact name as expected.
Bug in my code?
MSMessageTemplateLayout *templateLayout = [[MSMessageTemplateLayout alloc] init];
NSString *messageText = [NSString stringWithFormat:#"Challenged by $%#",
currentConversation.localParticipantIdentifier.UUIDString];
[templateLayout setSubcaption:messageText];
There is an open radar for it: https://openradar.appspot.com/26877873
Actually i am using MPMoviePlayerViewController in our app . And my code perfectly working in iOS 8.4 but when i upload my app into iPad (iOS 9 ) its not working ...
I am create ViewController to play two video one by one but when one video is completed or stop the controller going to my first page of app and behave unespected in iOS 9 .I am using custom MPMoviePlayerViewController to play video and put one button on first video to change other video but its not working...
NSURL *URL = [[NSBundle mainBundle] URLForResource:#"video" withExtension:#"mp4"];
self.indiaplayer = [[MPMoviePlayerController alloc] initWithContentURL:URL];
self.indiaplayer.view.frame = CGRectMake(0, 0,1024,718);
[self.indiavideoThumbnail addSubview: self.indiaplayer.view];
self.indiaplayer.controlStyle = MPMovieControlStyleNone;
self.indiaplayer.fullscreen = YES;
self.indiaplayer.repeatMode = YES;
[self.indiaplayer prepareToPlay];
self.indiaplayer.shouldAutoplay = NO;
self.indiaplaybackView = [[UIView alloc] initWithFrame:CGRectZero];
self.indiaplaybackView.backgroundColor = [UIColor colorWithRed:242.0/255 green:163.0/255 blue:10.0/255 alpha:1];
//self.playbackView.layer.cornerRadius = 2;
[indiaView addSubview:self.indiaplaybackView];
self.indiaslider.minimumValue = START;
self.indiaslider.maximumValue = END;
Thanks in advance
wait wait in iOS 9.x.x
IMPORTANT
The MPMoviePlayerViewController class is formally deprecated in iOS 9. (The MPMoviePlayerController class is also formally deprecated.) To play video content in iOS 9 and later, instead use the AVPictureInPictureController or AVPlayerViewController class from the AVKit framework, or the WKWebView class from WebKit.
For more detail
https://developer.apple.com/library/ios/documentation/MediaPlayer/Reference/MPMoviePlayerViewController_class/
I have some trouble with the new Core Spotlight API in iOS 9. The problem is that the init methods for CSSearchableItemAttributeSet returns nil. Here is an example that does not work for me:
CSSearchableItemAttributeSet* attributeSet = [[CSSearchableItemAttributeSet alloc] initWithItemContentType:(NSString *)kUTTypeImage];
attributeSet.title = movie.movieName;
attributeSet.contentDescription = movie.shortDescription ? movie.shortDescription : movie.longDescription;
attributeSet.thumbnailURL = [NSURL URLWithString: [movie posterURLStringWithWidth:100]];
the attributeSet is nil directly from start, so the last three lines does nothing. I have added the CoreSpotlight and MobileCoreService framework to the project and imported them in the same file. I have tried [[CSSearchableItemAttributeSet alloc] init] and this as well returns nil. I really can't figure out what I'm doing wrong. Using Xcode 7.0 beta 4. Any idea why it would return nil is highly appreciated!
From some trying back and forth I realised I did not have an iOS 9 beta installed on my phone which kind of explains why iOS 9 features does not work.. So, to answer my own question, you need to install iOS 9 (beta) when using CoreSpotlight.
Hello I Understand TTS is only available in iOS 7 but i used many apis in the past by checking if the class is available and managed to retain compatibility on previous versions but with AVSpeechSynthesizer it doesn't seem to work, can you please help me use TTS for iOS 7 and retain compatibility by disabling it in iOS 6, thank you very much.
Here is my code but it doesn't seem to work
if (([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.0)) {
if([AVSpeechSynthesizer class]) {
AVSpeechSynthesizer *synth = [[AVSpeechSynthesizer alloc] init];
AVSpeechUtterance *utterance = [AVSpeechUtterance speechUtteranceWithString:text];
utterance.voice = [AVSpeechSynthesisVoice voiceWithLanguage:#"en-US"];
utterance.rate = AVSpeechUtteranceDefaultSpeechRate/2;
utterance.pitchMultiplier = 0.9;
utterance.preUtteranceDelay = 0;
utterance.postUtteranceDelay = 0;
[synth speakUtterance:utterance];
} else {
// Feature not available, do something else
}
}
i've already linked avfoundation in my project and set deployment target iOS 6 and it seems to work only when runing on iOS 7 devices if its iOS 6 it crashes.
here is the error message i get
dyld: Symbol not found: _AVSpeechUtteranceDefaultSpeechRate
The framework needs to be be weak linked. Do the following:
Click your project file in the Project Navigator (on the left) to open your project in the editor
Click the Build Phases tab in the editor
Expand the Link Binary With Libraries section
Set AVFoundation.framework from Required to Optional
Additionally, you might want to update your version check with one that's safer (and recommended by Apple).