parent
681aa72bea
commit
af63582d43
@ -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 |
||||||
|
} |
||||||
|
} |
@ -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 |
||||||
|
} |
||||||
|
} |
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 |
||||||
|
} |
||||||
|
} |
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 |
||||||
|
} |
||||||
|
} |
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 |
||||||
|
} |
||||||
|
} |
After Width: | Height: | Size: 3.1 KiB |
@ -1,102 +1,161 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?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> |
<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="Safe area layout guides" minToolsVersion="9.0"/> |
||||||
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/> |
||||||
</dependencies> |
</dependencies> |
||||||
<scenes> |
<scenes> |
||||||
<!--First--> |
<!--Tab Bar Controller--> |
||||||
<scene sceneID="hNz-n2-bh7"> |
<scene sceneID="yl2-sM-qoP"> |
||||||
|
<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> |
||||||
|
<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> |
<objects> |
||||||
<viewController id="9pv-A4-QxB" customClass="FirstViewController" customModuleProvider="target" sceneMemberID="viewController"> |
<viewController id="Nbr-zX-YvN" customClass="PlayListController" customModule="cloudmusic" customModuleProvider="target" sceneMemberID="viewController"> |
||||||
<view key="view" contentMode="scaleToFill" id="tsR-hK-woN"> |
<view key="view" contentMode="scaleToFill" id="EMa-hO-vqt"> |
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> |
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> |
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> |
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> |
||||||
<subviews> |
<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"> |
<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"> |
||||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
<rect key="frame" x="0.0" y="277" width="414" height="536"/> |
||||||
<fontDescription key="fontDescription" type="system" pointSize="36"/> |
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> |
||||||
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/> |
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
||||||
<nil key="highlightedColor"/> |
</tableView> |
||||||
</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> |
|
||||||
</subviews> |
</subviews> |
||||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
||||||
<constraints> |
<viewLayoutGuide key="safeArea" id="Kug-6K-cM5"/> |
||||||
<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"/> |
|
||||||
</view> |
</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> |
</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> |
</objects> |
||||||
<point key="canvasLocation" x="750" y="-320"/> |
<point key="canvasLocation" x="-772" y="327"/> |
||||||
</scene> |
</scene> |
||||||
<!--Second--> |
<!--播放--> |
||||||
<scene sceneID="wg7-f3-ORb"> |
<scene sceneID="NDX-nT-lkJ"> |
||||||
<objects> |
<objects> |
||||||
<viewController id="8rJ-Kc-sve" customClass="SecondViewController" customModuleProvider="target" sceneMemberID="viewController"> |
<viewController id="IEQ-xx-jyn" userLabel="播放" customClass="PlayController" customModule="cloudmusic" customModuleProvider="target" sceneMemberID="viewController"> |
||||||
<view key="view" contentMode="scaleToFill" id="QS5-Rx-YEW"> |
<view key="view" contentMode="scaleToFill" id="6AL-ro-bLA"> |
||||||
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/> |
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> |
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> |
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> |
||||||
<subviews> |
<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"> |
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" id="C7Q-gs-clk"> |
||||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
<rect key="frame" x="87" y="126" width="240" height="128"/> |
||||||
<fontDescription key="fontDescription" type="system" pointSize="36"/> |
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> |
||||||
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/> |
</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"/> |
<nil key="highlightedColor"/> |
||||||
</label> |
</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"> |
<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"> |
||||||
<fontDescription key="fontDescription" type="system" pointSize="14"/> |
<rect key="frame" x="168" y="325" width="71" height="36"/> |
||||||
<color key="textColor" xcode11CocoaTouchSystemColor="labelColor" cocoaTouchSystemColor="darkTextColor"/> |
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/> |
||||||
|
<fontDescription key="fontDescription" type="system" pointSize="30"/> |
||||||
|
<nil key="textColor"/> |
||||||
<nil key="highlightedColor"/> |
<nil key="highlightedColor"/> |
||||||
</label> |
</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> |
</subviews> |
||||||
<color key="backgroundColor" xcode11CocoaTouchSystemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/> |
||||||
<constraints> |
<viewLayoutGuide key="safeArea" id="ybG-XY-4xE"/> |
||||||
<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"/> |
|
||||||
</view> |
</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> |
</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> |
</objects> |
||||||
<point key="canvasLocation" x="750" y="360"/> |
<point key="canvasLocation" x="811.59420289855075" y="108.48214285714285"/> |
||||||
</scene> |
</scene> |
||||||
<!--Tab Bar Controller--> |
<!--搜索--> |
||||||
<scene sceneID="yl2-sM-qoP"> |
<scene sceneID="Lpf-Iq-dQo"> |
||||||
<objects> |
<objects> |
||||||
<tabBarController id="49e-Tb-3d3" sceneMemberID="viewController"> |
<viewController id="2Ik-ns-MjT" customClass="SearchController" customModule="cloudmusic" customModuleProvider="target" sceneMemberID="viewController"> |
||||||
<tabBar key="tabBar" contentMode="scaleToFill" id="W28-zg-YXA"> |
<view key="view" contentMode="scaleToFill" id="TXN-a8-16h"> |
||||||
<rect key="frame" x="0.0" y="975" width="768" height="49"/> |
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/> |
||||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/> |
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> |
||||||
<color key="backgroundColor" red="0.0" green="0.0" blue="0.0" alpha="0.0" colorSpace="custom" customColorSpace="sRGB"/> |
<subviews> |
||||||
</tabBar> |
<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> |
<connections> |
||||||
<segue destination="9pv-A4-QxB" kind="relationship" relationship="viewControllers" id="u7Y-xg-7CH"/> |
<action selector="search:" destination="2Ik-ns-MjT" eventType="touchUpInside" id="EaR-J2-Pte"/> |
||||||
<segue destination="8rJ-Kc-sve" kind="relationship" relationship="viewControllers" id="lzU-1b-eKA"/> |
|
||||||
</connections> |
</connections> |
||||||
</tabBarController> |
</button> |
||||||
<placeholder placeholderIdentifier="IBFirstResponder" id="HuB-VB-40B" sceneMemberID="firstResponder"/> |
<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> |
||||||
|
<outlet property="keyword" destination="sEc-Yc-Wes" id="TTL-EO-sxq"/> |
||||||
|
<outlet property="musicTable" destination="6rp-N1-MZ4" id="4g5-vA-jpy"/> |
||||||
|
</connections> |
||||||
|
</viewController> |
||||||
|
<placeholder placeholderIdentifier="IBFirstResponder" id="hi6-z1-LHB" userLabel="First Responder" customClass="UIResponder" sceneMemberID="firstResponder"/> |
||||||
</objects> |
</objects> |
||||||
<point key="canvasLocation" x="0.0" y="0.0"/> |
<point key="canvasLocation" x="-1439.1304347826087" y="-37.5"/> |
||||||
</scene> |
</scene> |
||||||
</scenes> |
</scenes> |
||||||
<resources> |
<resources> |
||||||
<image name="first" width="30" height="30"/> |
<image name="list.dash" catalog="system" width="128" height="85"/> |
||||||
<image name="second" width="30" height="30"/> |
<image name="next" width="200" height="200"/> |
||||||
|
<image name="play" width="200" height="200"/> |
||||||
|
<image name="previous" width="200" height="200"/> |
||||||
</resources> |
</resources> |
||||||
</document> |
</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. |
|
||||||
} |
|
||||||
|
|
||||||
|
|
||||||
} |
|
||||||
|
|
@ -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! |
||||||
|
|
||||||
|
// 注意: Swift中mark注释的格式: 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数据源 |
||||||
|
// 必须实现UITableViewDataSource的option修饰的必须实现的方法,否则会报错 |
||||||
|
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.判断cell是否为nil |
||||||
|
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 { |
||||||
|
|
||||||
|
// 注意: Swift中mark注释的格式: 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"?> |
<?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=""> |
<model type="com.apple.IDECoreDataModeler.DataModel" documentVersion="1.0" lastSavedToolsVersion="16119" systemVersion="19F101" minimumToolsVersion="Automatic" sourceLanguage="Swift" userDefinedModelVersionIdentifier=""> |
||||||
<elements/> |
<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> |
</model> |
Loading…
Reference in new issue