在iOS App中显示用户的iTunes个人资料

时间:2016-01-20 10:03:24

标签: ios uiwebview itunes

我想在iPhone的屏幕上显示this iTunes链接。 我应该使用UIWebView还是别的什么?

    import UIKit

    class MusicViewController: UIViewController {
    @IBOutlet var itunesWebView: UIWebView!

    override func viewDidLoad() {
        super.viewDidLoad()

        let url = NSURL (string: "https://geo.itunes.apple.com/us/artist/seka-aleksic/id309535625?mt=1&app=music")
        let requestObj = NSURLRequest(URL: url!)
        itunesWebView.loadRequest(requestObj)

        /* INITIAL SETUP FOR COLOURS & FONTS */

        // Change the Navigation Bar Font to Lato
        navigationController?.navigationBar.titleTextAttributes =
            [NSForegroundColorAttributeName: UIColor.whiteColor(),
                NSFontAttributeName: UIFont(name: "Lato-Semibold", size: 20)!]

        // Set the Navigation Bar Text Color to White
        navigationController!.navigationBar.tintColor = UIColor.whiteColor()

        // Set the Background of the Table View
        let imageView = UIImageView(frame: self.view.frame)
        let image = UIImage(named: "main_menu_background")!
        imageView.image = image
        self.view.addSubview(imageView)
        self.view.sendSubviewToBack(imageView)
        /* INITIAL SETUP FOR COLOURS & FONTS */

    }


}

任何帮助都将受到高度赞赏

1 个答案:

答案 0 :(得分:0)

当然可以! 使用此:https://linkmaker.itunes.apple.com/en-us/?urlDesc=&country=us 它创建了一个可以共享的iTunes链接。 希望它对你有所帮助

如果您有问题,请问我

编辑:

UIWebView加载网址

使用链接(您的情况):

let url = NSURL (string: "https://geo.itunes.apple.com/us/app/clash-of-clans/id529479190?mt=8");
let requestObj = NSURLRequest(URL: url!);
yourWebView.loadRequest(requestObj);

使用HTML代码:

var htmlString:String! = "<br /><h2>Blaaaaa</h2>"
yourWebView.loadHTMLString(htmlString, baseURL: nil)

我的例子:https://www.dropbox.com/s/7z8xuidqedwhy2e/DragosStrugarHelp.zip?dl=0