小编Jea*_*ler的帖子

为什么iPhone 5不会旋转到upsideDown

我在我的代码中添加了新的方法,如苹果iOS 6 Documentations中所述,但在iPhone 5上,应用程序不会颠倒过来.只有景观方式.

这里我的代码来自rootViewController:

- (NSUInteger)supportedInterfaceOrientations{
    NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskLandscapeLeft |
            UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskPortraitUpsideDown);
}
- (BOOL)shouldAutorotate{
    NSLog(@">>> Entering %s <<<", __PRETTY_FUNCTION__);
    return YES;
}
Run Code Online (Sandbox Code Playgroud)

我也尝试了"UIInterfaceOrientationMaskAll"但没有变化.奇怪的是,我的带有iOS6的iPhone 4使用相同的代码完全颠倒了o.

有任何想法吗?

xcode rotation ios6

25
推荐指数
2
解决办法
2万
查看次数

如何检查AVPlayer是否有视频或仅音频?

我尝试播放一些"媒体",但在AVPlayer启动的时候,我不知道它是音频还是视频.

我连接了播放器层,它工作正常.

self.avPlayerLayer = [AVPlayerLayer playerLayerWithPlayer:[[PCPlayerManager sharedManager] audioPlayer]];
avPlayerLayer.videoGravity = AVLayerVideoGravityResizeAspect;
avPlayerLayer.frame = CGRectMake(0, 0, videoView.frame.size.width, videoView.frame.size.height);
[videoView.layer addSublayer:avPlayerLayer];
Run Code Online (Sandbox Code Playgroud)

但是,我如何检查是否有视频,以便我可以添加/删除一些选项?

audio video xcode avplayer

7
推荐指数
3
解决办法
3095
查看次数

可能在归属文本背景上有圆角吗?

我将Text归为不同的文本颜色.为了更好地阅读突出显示的文本,我使用backgroundcolor.是否有可能在这个Textarea上带来圆角的CALayer效果?不是整个区域,而是内部的特殊文本.

我的代码:

NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"Highlighted Text"
                                                                          attributes:@{
                                                                                       NSFontAttributeName:            [UIFont fontWithName:@"HelveticaNeue" size:10.0f],
                                                                                       NSForegroundColorAttributeName: [UIColor lightGrayColor],
                                                                                       NSBackgroundColorAttributeName: [UIColor darkGrayColor]
                                                                                       }];
Run Code Online (Sandbox Code Playgroud)

iphone nsattributedstring uilabel ios quartz-core

5
推荐指数
0
解决办法
5675
查看次数

NSAttributedString 在初始化时崩溃,但为什么呢?

有时这件事会崩溃,但我不知道为什么以及何时崩溃。有人有想法吗?

extension String {
var htmlDecoded: String? {

    if let encodedData = self.data(using: String.Encoding.utf8) as Data? {
        let attributedOptions = [ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
                                  NSCharacterEncodingDocumentAttribute: String.Encoding.utf8.rawValue] as [String : Any]
        do {
            let attributedString = try NSAttributedString(data: encodedData,
                                                          options: attributedOptions,
                                                          documentAttributes: nil)
            return attributedString.string

        } catch let error as NSError {
            print("ERROR: ", error.localizedDescription)

            return self
        }
    }
    return self
}
}
Run Code Online (Sandbox Code Playgroud)

这是我从 HockeyApp 得到的错误

function signature specialization <Arg[0] = Owned To Guaranteed and Exploded> of @nonobjc (extension in UIKit):__C.NSAttributedString.init(data: Foundation.Data, …
Run Code Online (Sandbox Code Playgroud)

encoding nsattributedstring swift

5
推荐指数
1
解决办法
1857
查看次数

Lockscreen中的iPod控件适用于自己的应用程序

如何在我自己的应用程序中使用锁屏iPod控件?

我尝试过MPNowPlayingInfoCenter,但如果我设置了信息,它就不会显示在任何地方; 不在锁屏上,也不在AppleTV上播放.

我使用AVPlayer播放我的音频文件.

iphone objective-c ios ios5

4
推荐指数
1
解决办法
2556
查看次数