搜索歌曲

master
panqihua 4 years ago
parent 681aa72bea
commit af63582d43
  1. 74
      cloudmusic.xcodeproj/project.pbxproj
  2. 2
      cloudmusic.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  3. 29
      cloudmusic/Alert.swift
  4. 5
      cloudmusic/AppDelegate.swift
  5. 21
      cloudmusic/Assets.xcassets/Pause.imageset/Contents.json
  6. BIN
      cloudmusic/Assets.xcassets/Pause.imageset/Pause.png
  7. 21
      cloudmusic/Assets.xcassets/next.imageset/Contents.json
  8. BIN
      cloudmusic/Assets.xcassets/next.imageset/next.png
  9. 21
      cloudmusic/Assets.xcassets/play.imageset/Contents.json
  10. BIN
      cloudmusic/Assets.xcassets/play.imageset/play.png
  11. 21
      cloudmusic/Assets.xcassets/previous.imageset/Contents.json
  12. BIN
      cloudmusic/Assets.xcassets/previous.imageset/previous.png
  13. 193
      cloudmusic/Base.lproj/Main.storyboard
  14. 20
      cloudmusic/FirstViewController.swift
  15. 7
      cloudmusic/Info.plist
  16. 33
      cloudmusic/MusicRequest.swift
  17. 36
      cloudmusic/PlayController.swift
  18. 83
      cloudmusic/PlayListController.swift
  19. 117
      cloudmusic/SearchController.swift
  20. 20
      cloudmusic/SecondViewController.swift
  21. 10
      cloudmusic/cloudmusic.xcdatamodeld/cloudmusic.xcdatamodel/contents

@ -3,20 +3,25 @@
archiveVersion = 1;
classes = {
};
objectVersion = 50;
objectVersion = 52;
objects = {
/* Begin PBXBuildFile section */
7151CAA824AFE14D004C4563 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAA724AFE14D004C4563 /* AppDelegate.swift */; };
7151CAAA24AFE14D004C4563 /* SceneDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAA924AFE14D004C4563 /* SceneDelegate.swift */; };
7151CAAC24AFE14D004C4563 /* FirstViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAAB24AFE14D004C4563 /* FirstViewController.swift */; };
7151CAAE24AFE14D004C4563 /* SecondViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAAD24AFE14D004C4563 /* SecondViewController.swift */; };
7151CAB124AFE14D004C4563 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7151CAAF24AFE14D004C4563 /* Main.storyboard */; };
7151CAB424AFE14D004C4563 /* cloudmusic.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAB224AFE14D004C4563 /* cloudmusic.xcdatamodeld */; };
7151CAB624AFE152004C4563 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7151CAB524AFE152004C4563 /* Assets.xcassets */; };
7151CAB924AFE152004C4563 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7151CAB724AFE152004C4563 /* LaunchScreen.storyboard */; };
7151CAC424AFE153004C4563 /* cloudmusicTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAC324AFE153004C4563 /* cloudmusicTests.swift */; };
7151CACF24AFE153004C4563 /* cloudmusicUITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CACE24AFE153004C4563 /* cloudmusicUITests.swift */; };
7151CADF24AFE612004C4563 /* PlayListController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CADE24AFE612004C4563 /* PlayListController.swift */; };
7151CAEA24AFFE6B004C4563 /* Alamofire in Frameworks */ = {isa = PBXBuildFile; productRef = 7151CAE924AFFE6B004C4563 /* Alamofire */; };
7151CAEC24B001EF004C4563 /* MusicRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAEB24B001EE004C4563 /* MusicRequest.swift */; };
7151CAEE24B00ED4004C4563 /* PlayController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAED24B00ED4004C4563 /* PlayController.swift */; };
7151CAF024B01A6B004C4563 /* SearchController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CAEF24B01A6B004C4563 /* SearchController.swift */; };
7151CAF524B02DDA004C4563 /* SwiftyJSON in Frameworks */ = {isa = PBXBuildFile; productRef = 7151CAF424B02DDA004C4563 /* SwiftyJSON */; };
7151CB0124B042BC004C4563 /* Alert.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7151CB0024B042BC004C4563 /* Alert.swift */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -40,8 +45,6 @@
7151CAA424AFE14D004C4563 /* cloudmusic.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = cloudmusic.app; sourceTree = BUILT_PRODUCTS_DIR; };
7151CAA724AFE14D004C4563 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7151CAA924AFE14D004C4563 /* SceneDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SceneDelegate.swift; sourceTree = "<group>"; };
7151CAAB24AFE14D004C4563 /* FirstViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FirstViewController.swift; sourceTree = "<group>"; };
7151CAAD24AFE14D004C4563 /* SecondViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecondViewController.swift; sourceTree = "<group>"; };
7151CAB024AFE14D004C4563 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
7151CAB324AFE14D004C4563 /* cloudmusic.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = cloudmusic.xcdatamodel; sourceTree = "<group>"; };
7151CAB524AFE152004C4563 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
@ -53,6 +56,11 @@
7151CACA24AFE153004C4563 /* cloudmusicUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = cloudmusicUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
7151CACE24AFE153004C4563 /* cloudmusicUITests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = cloudmusicUITests.swift; sourceTree = "<group>"; };
7151CAD024AFE153004C4563 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
7151CADE24AFE612004C4563 /* PlayListController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayListController.swift; sourceTree = "<group>"; };
7151CAEB24B001EE004C4563 /* MusicRequest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MusicRequest.swift; sourceTree = "<group>"; };
7151CAED24B00ED4004C4563 /* PlayController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlayController.swift; sourceTree = "<group>"; };
7151CAEF24B01A6B004C4563 /* SearchController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SearchController.swift; sourceTree = "<group>"; };
7151CB0024B042BC004C4563 /* Alert.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Alert.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -60,6 +68,8 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
7151CAF524B02DDA004C4563 /* SwiftyJSON in Frameworks */,
7151CAEA24AFFE6B004C4563 /* Alamofire in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -105,13 +115,16 @@
children = (
7151CAA724AFE14D004C4563 /* AppDelegate.swift */,
7151CAA924AFE14D004C4563 /* SceneDelegate.swift */,
7151CAAB24AFE14D004C4563 /* FirstViewController.swift */,
7151CAAD24AFE14D004C4563 /* SecondViewController.swift */,
7151CAAF24AFE14D004C4563 /* Main.storyboard */,
7151CAB524AFE152004C4563 /* Assets.xcassets */,
7151CAB724AFE152004C4563 /* LaunchScreen.storyboard */,
7151CABA24AFE152004C4563 /* Info.plist */,
7151CAB224AFE14D004C4563 /* cloudmusic.xcdatamodeld */,
7151CADE24AFE612004C4563 /* PlayListController.swift */,
7151CAEB24B001EE004C4563 /* MusicRequest.swift */,
7151CAED24B00ED4004C4563 /* PlayController.swift */,
7151CAEF24B01A6B004C4563 /* SearchController.swift */,
7151CB0024B042BC004C4563 /* Alert.swift */,
);
path = cloudmusic;
sourceTree = "<group>";
@ -150,6 +163,10 @@
dependencies = (
);
name = cloudmusic;
packageProductDependencies = (
7151CAE924AFFE6B004C4563 /* Alamofire */,
7151CAF424B02DDA004C4563 /* SwiftyJSON */,
);
productName = cloudmusic;
productReference = 7151CAA424AFE14D004C4563 /* cloudmusic.app */;
productType = "com.apple.product-type.application";
@ -222,6 +239,10 @@
Base,
);
mainGroup = 7151CA9B24AFE14D004C4563;
packageReferences = (
7151CAE824AFFE6B004C4563 /* XCRemoteSwiftPackageReference "Alamofire" */,
7151CAF324B02DDA004C4563 /* XCRemoteSwiftPackageReference "SwiftyJSON" */,
);
productRefGroup = 7151CAA524AFE14D004C4563 /* Products */;
projectDirPath = "";
projectRoot = "";
@ -265,10 +286,13 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
7151CAAE24AFE14D004C4563 /* SecondViewController.swift in Sources */,
7151CB0124B042BC004C4563 /* Alert.swift in Sources */,
7151CAEE24B00ED4004C4563 /* PlayController.swift in Sources */,
7151CADF24AFE612004C4563 /* PlayListController.swift in Sources */,
7151CAB424AFE14D004C4563 /* cloudmusic.xcdatamodeld in Sources */,
7151CAAC24AFE14D004C4563 /* FirstViewController.swift in Sources */,
7151CAEC24B001EF004C4563 /* MusicRequest.swift in Sources */,
7151CAA824AFE14D004C4563 /* AppDelegate.swift in Sources */,
7151CAF024B01A6B004C4563 /* SearchController.swift in Sources */,
7151CAAA24AFE14D004C4563 /* SceneDelegate.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -593,6 +617,38 @@
};
/* End XCConfigurationList section */
/* Begin XCRemoteSwiftPackageReference section */
7151CAE824AFFE6B004C4563 /* XCRemoteSwiftPackageReference "Alamofire" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/Alamofire/Alamofire.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.2.1;
};
};
7151CAF324B02DDA004C4563 /* XCRemoteSwiftPackageReference "SwiftyJSON" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/SwiftyJSON/SwiftyJSON.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 5.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */
/* Begin XCSwiftPackageProductDependency section */
7151CAE924AFFE6B004C4563 /* Alamofire */ = {
isa = XCSwiftPackageProductDependency;
package = 7151CAE824AFFE6B004C4563 /* XCRemoteSwiftPackageReference "Alamofire" */;
productName = Alamofire;
};
7151CAF424B02DDA004C4563 /* SwiftyJSON */ = {
isa = XCSwiftPackageProductDependency;
package = 7151CAF324B02DDA004C4563 /* XCRemoteSwiftPackageReference "SwiftyJSON" */;
productName = SwiftyJSON;
};
/* End XCSwiftPackageProductDependency section */
/* Begin XCVersionGroup section */
7151CAB224AFE14D004C4563 /* cloudmusic.xcdatamodeld */ = {
isa = XCVersionGroup;

@ -2,6 +2,6 @@
<Workspace
version = "1.0">
<FileRef
location = "self:cloudmusic.xcodeproj">
location = "self:">
</FileRef>
</Workspace>

@ -0,0 +1,29 @@
//
// Alert.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
import CoreData
extension UIViewController{
func alert(message:String,title:String="警告信息",preferredStyle:UIAlertController.Style=UIAlertController.Style.alert,style:UIAlertAction.Style=UIAlertAction.Style.destructive){
let alertController = UIAlertController(title: title, message: message, preferredStyle: preferredStyle)
alertController.addAction(UIAlertAction(title: "确认", style:style, handler: nil))
self.present(alertController, animated: true, completion: nil)
}
//
func getContext()-> NSManagedObjectContext {
//
let appDelegate = UIApplication.shared.delegate as! AppDelegate
//
//let managedObjectContect = appDelegate.persistentContainer.viewContext
//
return appDelegate.persistentContainer.viewContext
}
}

@ -77,6 +77,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
}
}
}
}

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "Pause.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "next.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "play.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB

@ -0,0 +1,21 @@
{
"images" : [
{
"filename" : "previous.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"scale" : "2x"
},
{
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

@ -1,102 +1,161 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="13122.16" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="49e-Tb-3d3">
<device id="retina6_1" orientation="portrait" appearance="light"/>
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="13104.12"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--First-->
<scene sceneID="hNz-n2-bh7">
<!--Tab Bar Controller-->
<scene sceneID="yl2-sM-qoP">
<objects>
<viewController id="9pv-A4-QxB" customClass="FirstViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="tsR-hK-woN">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<tabBarController id="49e-Tb-3d3" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" id="W28-zg-YXA">
<rect key="frame" x="0.0" y="975" width="768" height="49"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</tabBar>
<connections>
<segue destination="IEQ-xx-jyn" kind="relationship" relationship="viewControllers" id="cXW-NO-enO"/>
<segue destination="2Ik-ns-MjT" kind="relationship" relationship="viewControllers" id="GBv-jG-mkF"/>
<segue destination="Nbr-zX-YvN" kind="relationship" relationship="viewControllers" id="jx4-0W-bTc"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="17" y="-32"/>
</scene>
<!--播放列表-->
<scene sceneID="2k2-gH-VMe">
<objects>
<viewController id="Nbr-zX-YvN" customClass="PlayListController" customModule="cloudmusic" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="EMa-hO-vqt">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="First View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="KQZ-1w-vlD">
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<fontDescription key="fontDescription" type="system" pointSize="36"/>
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by FirstViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="A5M-7J-77L">
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<nil key="highlightedColor"/>
</label>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="W8B-5A-Ehd">
<rect key="frame" x="0.0" y="277" width="414" height="536"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</tableView>
</subviews>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="KQZ-1w-vlD" secondAttribute="centerX" id="6BV-lF-sBN"/>
<constraint firstItem="A5M-7J-77L" firstAttribute="top" secondItem="KQZ-1w-vlD" secondAttribute="bottom" constant="8" symbolic="YES" id="cfb-er-3JN"/>
<constraint firstItem="A5M-7J-77L" firstAttribute="centerX" secondItem="KQZ-1w-vlD" secondAttribute="centerX" id="e1l-AV-tCB"/>
<constraint firstAttribute="centerY" secondItem="KQZ-1w-vlD" secondAttribute="centerY" id="exm-UA-ej4"/>
</constraints>
<viewLayoutGuide key="safeArea" id="PQr-Ze-W5v"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="Kug-6K-cM5"/>
</view>
<tabBarItem key="tabBarItem" title="First" image="first" id="acW-dT-cKf"/>
<tabBarItem key="tabBarItem" title="播放列表" image="list.dash" catalog="system" id="ZCe-nL-ME8"/>
<connections>
<outlet property="table" destination="W8B-5A-Ehd" id="kW2-0h-Z2U"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="W5J-7L-Pyd" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="kF2-IP-0Wq" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="750" y="-320"/>
<point key="canvasLocation" x="-772" y="327"/>
</scene>
<!--Second-->
<scene sceneID="wg7-f3-ORb">
<!--播放-->
<scene sceneID="NDX-nT-lkJ">
<objects>
<viewController id="8rJ-Kc-sve" customClass="SecondViewController" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="QS5-Rx-YEW">
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
<viewController id="IEQ-xx-jyn" userLabel="播放" customClass="PlayController" customModule="cloudmusic" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="6AL-ro-bLA">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" text="Second View" textAlignment="center" lineBreakMode="tailTruncation" minimumFontSize="10" translatesAutoresizingMaskIntoConstraints="NO" id="zEq-FU-wV5">
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<fontDescription key="fontDescription" type="system" pointSize="36"/>
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="C7Q-gs-clk">
<rect key="frame" x="87" y="126" width="240" height="128"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="IIQ-1o-bMh">
<rect key="frame" x="168" y="281" width="71" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Loaded by SecondViewController" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="NDk-cv-Gan">
<fontDescription key="fontDescription" type="system" pointSize="14"/>
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Ryn-W9-Eef">
<rect key="frame" x="168" y="325" width="71" height="36"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="30"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<progressView opaque="NO" contentMode="scaleToFill" verticalHuggingPriority="750" fixedFrame="YES" progress="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="nSL-9z-TOF">
<rect key="frame" x="87" y="447" width="256" height="2"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</progressView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="previous" id="cje-ai-bPk">
<rect key="frame" x="87" y="600" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="next" id="JAt-Tx-hWz">
<rect key="frame" x="293" y="600" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="play" id="Koi-FD-jGR">
<rect key="frame" x="189" y="600" width="50" height="50"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
</imageView>
</subviews>
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<constraints>
<constraint firstItem="NDk-cv-Gan" firstAttribute="top" secondItem="zEq-FU-wV5" secondAttribute="bottom" constant="8" symbolic="YES" id="Day-4N-Vmt"/>
<constraint firstItem="NDk-cv-Gan" firstAttribute="centerX" secondItem="zEq-FU-wV5" secondAttribute="centerX" id="JgO-Fn-dHn"/>
<constraint firstAttribute="centerX" secondItem="zEq-FU-wV5" secondAttribute="centerX" id="qqM-NS-xev"/>
<constraint firstAttribute="centerY" secondItem="zEq-FU-wV5" secondAttribute="centerY" id="qzY-Ky-pLD"/>
</constraints>
<viewLayoutGuide key="safeArea" id="O1u-W8-tvY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="ybG-XY-4xE"/>
</view>
<tabBarItem key="tabBarItem" title="Second" image="second" id="cPa-gy-q4n"/>
<tabBarItem key="tabBarItem" title="播放" id="LTq-mh-JP7"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<outlet property="progress" destination="nSL-9z-TOF" id="J9o-AG-9GH"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="4Nw-L8-lE0" sceneMemberID="firstResponder"/>
<placeholder placeholderIdentifier="IBFirstResponder" id="1bd-h6-NBe" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="750" y="360"/>
<point key="canvasLocation" x="811.59420289855075" y="108.48214285714285"/>
</scene>
<!--Tab Bar Controller-->
<scene sceneID="yl2-sM-qoP">
<!--搜索-->
<scene sceneID="Lpf-Iq-dQo">
<objects>
<tabBarController id="49e-Tb-3d3" sceneMemberID="viewController">
<tabBar key="tabBar" contentMode="scaleToFill" id="W28-zg-YXA">
<rect key="frame" x="0.0" y="975" width="768" height="49"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/>
</tabBar>
<viewController id="2Ik-ns-MjT" customClass="SearchController" customModule="cloudmusic" customModuleProvider="target" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="TXN-a8-16h">
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<textField opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" borderStyle="roundedRect" placeholder="请输入关键词" textAlignment="natural" minimumFontSize="17" id="sEc-Yc-Wes">
<rect key="frame" x="57" y="227" width="201" height="39.5"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<textInputTraits key="textInputTraits"/>
</textField>
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" id="tUw-aS-iW0">
<rect key="frame" x="293" y="224" width="51" height="42"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="25"/>
<state key="normal" title="搜索"/>
<connections>
<action selector="search:" destination="2Ik-ns-MjT" eventType="touchUpInside" id="EaR-J2-Pte"/>
</connections>
</button>
<tableView clipsSubviews="YES" contentMode="scaleToFill" fixedFrame="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="28" sectionFooterHeight="28" translatesAutoresizingMaskIntoConstraints="NO" id="6rp-N1-MZ4">
<rect key="frame" x="37" y="304" width="344" height="480"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
</tableView>
</subviews>
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
<viewLayoutGuide key="safeArea" id="X1b-Gk-lAx"/>
</view>
<tabBarItem key="tabBarItem" title="搜索" id="6FF-jA-ogW"/>
<simulatedTabBarMetrics key="simulatedBottomBarMetrics"/>
<connections>
<segue destination="9pv-A4-QxB" kind="relationship" relationship="viewControllers" id="u7Y-xg-7CH"/>
<segue destination="8rJ-Kc-sve" kind="relationship" relationship="viewControllers" id="lzU-1b-eKA"/>
<outlet property="keyword" destination="sEc-Yc-Wes" id="TTL-EO-sxq"/>
<outlet property="musicTable" destination="6rp-N1-MZ4" id="4g5-vA-jpy"/>
</connections>
</tabBarController>
<placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="hi6-z1-LHB" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="0.0" y="0.0"/>
<point key="canvasLocation" x="-1439.1304347826087" y="-37.5"/>
</scene>
</scenes>
<resources>
<image name="first" width="30" height="30"/>
<image name="second" width="30" height="30"/>
<image name="list.dash" catalog="system" width="128" height="85"/>
<image name="next" width="200" height="200"/>
<image name="play" width="200" height="200"/>
<image name="previous" width="200" height="200"/>
</resources>
</document>

@ -1,20 +0,0 @@
//
// FirstViewController.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
class FirstViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}

@ -18,8 +18,15 @@
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSApplicationCategoryType</key>
<string></string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIApplicationSceneManifest</key>
<dict>
<key>UIApplicationSupportsMultipleScenes</key>

@ -0,0 +1,33 @@
//
// MusicRequest.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
import Alamofire
import SwiftyJSON
//
class MusicRequest: NSObject {
//
private static let request_host = "192.168.50.73:5000"
//
static func search(keyword:String,callback:@escaping (JSON?) -> Void ){
let url="http://\(String(describing: request_host))/search?keywords=\(keyword)"
debugPrint("搜索请求接口地址:\(url)")
AF.request(url).responseJSON { response in
debugPrint(response)
if let json = try? JSON(data: response.data!){
callback(json)
}else{
callback(nil)
}
}
}
}

@ -0,0 +1,36 @@
//
// PlayController.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
class PlayController: UIViewController {
@IBOutlet weak var progress: UIProgressView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
progress.transform = CGAffineTransform(scaleX: 1, y: 3.0)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}

@ -0,0 +1,83 @@
//
// PlayListController.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
class PlayListController: UIViewController {
@IBOutlet weak var table: UITableView!
// : Swiftmark: MARK:-
// MARK:-
let cellID = "cell"
override func viewDidLoad() {
super.viewDidLoad()
//
table.dataSource = self
table.delegate = self
// cell
table.register(UITableViewCell.self, forCellReuseIdentifier: cellID)
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
extension PlayListController: UITableViewDataSource,UITableViewDelegate{
// MARK:- UITableViewDataSource
// UITableViewDataSourceoption,
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 20
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
/*
// ----------------------------------------------------------------
// 使cell
let cellID = "cell"
// 1.cell,cell
var cell = tableView.dequeueReusableCellWithIdentifier(cellID)
// 2.cellnil
if cell == nil {
cell = UITableViewCell(style: .Default, reuseIdentifier: cellID)
}
// 3.cell
cell?.textLabel?.text = "测试数据\(indexPath.row)"
return cell!
*/
let cell = tableView.dequeueReusableCell(withIdentifier: cellID)
cell?.textLabel?.text = "测试数据\(indexPath.row)"
return cell! }
// MARK:- UITableViewDelegate
private func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
print("点击了\(indexPath.row)")
}
}

@ -0,0 +1,117 @@
//
// SearchController.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
import SwiftyJSON
import CoreData
class SearchController: UIViewController {
// : Swiftmark: MARK:-
// MARK:-
let cellID = "cell"
//
@IBOutlet weak var keyword: UITextField!
//
@IBOutlet weak var musicTable: UITableView!
//
var musicList:[cloudmusic.Music]=[]
//
@IBAction func search(_ sender: UIButton) {
self.textFieldShouldReturn(keyword)
if let k=keyword{
if k.text!.count>0{
MusicRequest.search(keyword: k.text!,callback: {(json) in
debugPrint("json:\(String(describing: json))")
if let res=json{
if res["code"]==200{
self.musicList=[]
for (_,subJson):(String, JSON) in res["result"]["songs"] {
// debugPrint("index=\(index),subJson=\(subJson)")
let context=self.getContext()
let music = NSEntityDescription.insertNewObject(forEntityName: "Music", into: context) as! Music
music.id=subJson["id"].int64Value
music.name=subJson["name"].stringValue
debugPrint("id=\(music.id),name=\(String(describing: music.name))")
self.musicList.append(music)
}
self.musicTable.reloadData()
self.musicTable.isHidden=false
}else{
self.alert(message: "请求失败,请稍后再试")
}
}else{
self.alert(message: "请求失败,请稍后再试")
}
})
}else{
self.alert(message: "关键词不能为空")
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
//
self.musicTable.dataSource = self
self.musicTable.delegate = self
self.musicTable.isHidden=true
// cell
self.musicTable.register(UITableViewCell.self, forCellReuseIdentifier: cellID)
self.keyword.delegate=self
self.keyword.returnKeyType=UIReturnKeyType.done
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destination.
// Pass the selected object to the new view controller.
}
*/
}
extension SearchController: UITableViewDataSource,UITableViewDelegate{
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return musicList.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: cellID)
cell?.textLabel?.text = "歌曲名:\(String(describing: musicList[indexPath.row].name!))"
return cell!
}
}
extension SearchController:UITextFieldDelegate{
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
self.keyword.resignFirstResponder()
return true
}
func textFieldDidEndEditing(_ textField: UITextField) {
self.search(UIButton())
}
}

@ -1,20 +0,0 @@
//
// SecondViewController.swift
// cloudmusic
//
// Created by Qihua Pan on 2020/7/3.
// Copyright © 2020 Qihua Pan. All rights reserved.
//
import UIKit
class SecondViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
}

@ -1,4 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="1" systemVersion="11A491" minimumToolsVersion="Automatic" sourceLanguage="Swift" usedWithCloudKit="false" userDefinedModelVersionIdentifier="">
<elements/>
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="16119" systemVersion="19F101" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier="">
<entity name="Music" representedClassName="Music" syncable="YES" codeGenerationType="class">
<attribute name="id" optional="YES" attributeType="Integer 64" defaultValueString="0" usesScalarValueType="YES"/>
<attribute name="name" optional="YES" attributeType="String"/>
</entity>
<elements>
<element name="Music" positionX="-45" positionY="0" width="128" height="73"/>
</elements>
</model>
Loading…
Cancel
Save