iOS 独立开发记录(下)

侧边菜单栏

查看Github上相关实现,一开始选择的是SlideMenuControllerSwift,后来决定更改为自定义,使用更简洁的方式。

分离

分离之前的SliderMeanController,再添加动画。

1.MainViewControllerremove:

extension MainViewController:SlideMenuControllerDelegate{

   func leftWillOpen() {

      print("SlideMenuControllerDelegate: leftWillOpen")

       OnceOpened = true

   }

   func leftDidOpen() {

       print("SlideMenuControllerDelegate: leftDidOpen")

   }

   func leftWillClose() {

       print("SlideMenuControllerDelegate: leftWillClose")

       noteLabel.text = "(metronome.noteNum)"

       metreLabel.text = "(metronome.metreView.numMetre)"

       tempoLabel.text = "(metronome.tempo)"

       tempoItalianName(italianName)

       initialHandelPoint()

       metronome.metreView.setNeedsDisplay()

       print("subview count:")

       print(view.subviews.count)

       self.ball.setNeedsDisplay()

   }

   func leftDidClose() {

       print("SlideMenuControllerDelegate: leftDidClose")

   }  

   }

LeftViewController

remove:

wiilappear:

initialMenu()

class里面:

weak var delegate: LeftMenuProtocol?

func initialMenu() {

let storyboard = UIStoryboard(name: "Main", bundle: nil)

let nonMenuController = storyboard.instantiateViewControllerWithIdentifier("purchaseViewController") as! PurchaseViewController

nonMenuController.delegate = self

self.nonMenuViewController = UINavigationController(rootViewController: nonMenuController)

  }

class 前:

enum LeftMenu: Int {

       case Main = 0

   }

   protocol LeftMenuProtocol : class {

       func changeViewController(menu: LeftMenu)

   }

  class extension:

   // MARK: - LeftMenuProtocol

   extension LeftViewController: LeftMenuProtocol{

       func changeViewController(menu: LeftMenu) {

           switch menu {

           case .Main:

               self.slideMenuController()?.changeMainViewController(self.mainViewController,          close: true)

           }

       }

   }

alert 转场:

self.slideMenuController()?.

        changeMainViewController(self.nonMenuViewController, close: true)

App delegate里面:

private func createMenuView() {

      // create viewController code...

      let storyboard = UIStoryboard(name: "Main", bundle: nil)

      let mainViewController = storyboard.instantiateViewControllerWithIdentifier("MainViewController") as! MainViewController

      let leftViewController = storyboard.instantiateViewControllerWithIdentifier("LeftViewController") as! LeftViewController

      let mvc: UINavigationController = UINavigationController(rootViewController: mainViewController)

      UINavigationBar.appearance().tintColor = UIColor(hex: "689F38")

      leftViewController.mainViewController = mvc

      let slideMenuController = ExSlideMenuController(mainViewController:mvc, leftMenuViewController: leftViewController)

      slideMenuController.automaticallyAdjustsScrollViewInsets = true

      slideMenuController.delegate = mainViewController

      //        self.window?.backgroundColor = UIColor(red: 236.0, green: 238.0, blue: 241.0, alpha: 1.0)

      self.window?.rootViewController = slideMenuController

      self.window?.makeKeyAndVisible()

  }

purchaseViewCont:

class 里面:

weak var delegate: LeftMenuProtocol?

        func done() {

      delegate?.changeViewController(LeftMenu.Main)

  }

        override func viewWillAppear(animated: Bool) {

      super.viewWillAppear(animated)

      self.removeNavigationBarItem()

      let doneTitle = NSLocalizedString("doneTitle", comment: "Purchase done title")

      let rightButton: UIBarButtonItem = UIBarButtonItem(title: doneTitle, style: .Plain, target: self, action: #selector(done))

      navigationItem.rightBarButtonItem = rightButton

动画Spring Animation

我使用的是MengTo的Spring动画库。

内购

技术参考:

https://developer.apple.com/in-app-purchase/

https://www.raywenderlich.com/122144/in-app-purchase-tutorial

https://www.raywenderlich.com/121218/video-tutorial-in-app-purchase-series-introduction

https://github.com/mattt/Ono

https://github.com/awseeley/Swift-In-App-Purchase-Tutorial

页面实现:

How to make a beautiful page for the purchase?

使用Collection View,使用卡片展示。

声音

Where to find the good sound?

推荐网站:

  • https://www.freesound.org/people/toiletrolltube/sounds/345691/

  • http://www.findsounds.com/ISAPI/search.dll?keywords=drum+solo

声音下载之后需要自己进行一些细化处理,推荐Sound Studio,它小而简洁,进行简单的处理足够了。

 

 

后台播放

参考书籍:iOS8 Programming

Appledelegate:

func application(application: UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool  {

    // paly on the background

    _ = try? AVAudioSession.sharedInstance().setCategory(AVAudioSessionCategoryAmbient, withOptions: [])

    // others

  }

      func applicationWillResignActive(application: UIApplication) {

    _ = try? AVAudioSession.sharedInstance().setActive(true, withOptions: [])

}

func applicationDidBecomeActive(application: UIApplication) {

    _ = try? AVAudioSession.sharedInstance().setActive(true, withOptions: [])

  }

细节问题

问题:

为什么nav颜色无法更改,感觉蒙上了一层影?

解决:

参考:

Swift: https://github.com/DanisFabric/RainbowNavigation

p.p1 {margin: 0.0px 0.0px 0.0px 60.0px; font: 16.0px ‘Helvetica Neue’; color: #999999}p.p2 {margin: 0.0px 0.0px 0.0px 60.0px; font: 16.0px ‘Helvetica Neue’; color: #999999; min-height: 18.0px}span.s1 {font: 16.0px ‘PingFang SC’}span.Apple-tab-span {white-space:pre}

Swift: https://github.com/DanisFabric/RainbowNavigation

sBarMask?.autoresizingMask = [.FlexibleWidth,.FlexibleHeight]

             if let tempBackgroundView = backgroundView {

                 insertSubview(statusBarMask!, aboveSubview: tempBackgroundView)

             }else {

                 insertSubview(statusBarMask!, atIndex: 0)

             }

         }

         statusBarMask?.backgroundColor = color

     }

     public func df_setBackgroundColor(color: UIColor) {

         if backgroundView == nil {

             setBackgroundImage(UIImage(), forBarMetrics: UIBarMetrics.Default)

             shadowImage = UIImage()

             backgroundView = UIView(frame: CGRect(x: 0, y: -20, width: UIScreen.mainScreen().bounds.width, height: 64))

             backgroundView?.userInteractionEnabled = false

             backgroundView?.autoresizingMask = [.FlexibleHeight,.FlexibleWidth]

             insertSubview(backgroundView!, atIndex: 0)

         }

         backgroundView?.backgroundColor = color

     }

     public func df_reset() {

         setBackgroundImage(nil, forBarMetrics: .Default)

         shadowImage = nil

         backgroundView?.removeFromSuperview()

         backgroundView = nil

     }

     // MARK: Properties

     private var backgroundView:UIView? {

         get {

             return objc_getAssociatedObject(self, &kBackgroundViewKey) as? UIView

         }

         set {

             objc_setAssociatedObject(self, &kBackgroundViewKey, newValue, .OBJC_ASSOCIATION_RETAIN)

         }

     }

     private var statusBarMask:UIView? {

         get {

             return objc_getAssociatedObject(self, &kStatusBarMaskKey) as? UIView

         }

         set {

             objc_setAssociatedObject(self, &kStatusBarMaskKey, newValue, .OBJC_ASSOCIATION_RETAIN)

         }

     }

}

在MainViewController中添加:

self.navigationController?.navigationBar.df_setBackgroundColor(UIColor.clearColor())

 

为什么点击按钮之后,图片位置会改变?

改变UIButton的image之后,它的位置也会改变,需要将之前的先存储,改变图片之后再赋给它。

CGPoint currentLoc = self.imageButton.center;

[self.imageButton setImage:[UIImage imageNamed:@”face”] forState:UIControlStateNormal];

self.imageButton.center = currentLoc;

好像不是这个问题。我把外面的View去掉一层就OK了。

UIScrollerView

UIScrollerView的contentSize是取决于其子视图的,所以一定要通过子视图来限制其大小。

UIScrollerView需要探索的地方还很多,比如像相册这样的应用,是两个scrollerView,一个用来zoom,一个用来左右切换。

测试

TestFlight测试 (外部测试需审核)

其他第三方测试 (无需审核)

发布

  • 如何取好App名字?

  • 如何写好App介绍?

  • 制作App简短视频?

网站

因为也做过一些网站,用Bootstrap写过前端,PHP写过后台。基本的HTML/CSS,JS都会些,所以做网站对我来说没什么问题。不过,你不需要那么多知识,你可以在直接使用模板,再进行修改即可。

  • 选择模板

  • 准备内容素材(图片、文字、链接)

最终效果:http://azureyu.com/pulse

截图

素材:

  • 在设备上运行,同时按home+电源键进行截图

  • 或者使用模拟器运行之后按Command+S,即可保持截图

AppStore介绍截图制作:

  • 使用Sketch

  • 推荐模板:https://github.com/LaunchKit/SketchToAppStore

  • 思考介绍内容,编辑,修改,再修改,再修改

  • 导出

视频

录制步骤:

  1. 连接设备

  2. 打开QuickTime Player

  3. 进行文件影片录制

  4. 使用iMovie进行剪辑,iMove中可直接新建应用商店预览视频。

Tips:

  1. 视频上传需使用Safair浏览器,最好用iMovie中直接选择导出为应用商店预览视频。这样不会出现视屏帧数太多等问题。

  2. 如何旋转视频?使用QuickTime Player打开,然后在菜单中选择编辑,向左选择即可。

最好将所有素材放在同一个文件夹中,按照一定的命名方式进行整理。

上传

https://developer.apple.com/app-store/cn/

https://itunespartner.apple.com/cn/apps/videos

https://app.grammarly.com/ 避免英语文法错误

介绍

English:

Pulse is a clean and beautiful Metronome. It helps you better your music feeling and skill. With Pulse, your play time will be much more joyful.

Features:

  • Colorful Themes. There are ten attractive themes that you can choose: night, tree, coffee, pink, azure, blue, purple…… make your play time more colorful.

  • Nice Sounds. You can hear the different kinds of sounds: wood, ping, claves, triangle, shaker, blocks……choice the one suit your ear.

  • Save setlist. You can save the setlist that you often play, it’s easy to use.

  • Swing. You can visualize the time passing, see the movements. In Pulse, there are 7 swing types: none, small, medium, large, ball, square, diamond. It always has the one you want.

Others:

  • Play on the lock mood and background.

  • Universal app, available on you iPod touch、iPhone and iPad.

Support :

中文:

律动是一款简洁而美观的节拍器。它能够帮助你提升乐感和技能。缤纷的主题,悦耳的音色,可视化时间流逝的钟摆都能让你的练习更为多彩。

特点:

  • 十种主题缤纷主题任你选择:碳黑、咖啡、森林、粉红、蔚蓝、紫藤、翠绿等。

  • 十余种悦耳音色舒适双耳:实木、沙铃、三角铁、铃环、木鱼、鼓、钢琴、铁、铛等。

  • 一键保存演出列表:一键保持你的演出列表,节约你的时间,方便你的练习。

  • 7种钟摆模式:无, 小, 中, 长, 球, 方, 菱。可视化时间流逝的最佳选择。

其他:

  • 支持锁屏播放和后台播放

  • 支持屏幕常量

  • 支持所有iPod Touch、iPhone和iPad设备

反馈:

被拒5-24

版本上传错误。

再次被拒

Apple审核团队说App会在iPad Air下点击菜单按钮会crash,可是测试了很多次之后,我都没能重现crash,和他们沟通无果。等了两天,我在代码原封不动的情况下,重新build了一个版本,再上传,就通过了。

审核通过 6-1

Market

  • 产品推荐网站 :例如36NEXT,MindStore之类。

  • Weibo Twitter BBS

用户会去哪些地方?

原文地址:https://www.cnblogs.com/fengmin/p/5576559.html