Skip to content

Commit

Permalink
第22天—3DTouch
Browse files Browse the repository at this point in the history
1.升级api
2.修复bug
  • Loading branch information
qianyb committed Dec 26, 2018
1 parent 6facf60 commit 7e6387f
Show file tree
Hide file tree
Showing 16 changed files with 232 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -197,18 +197,24 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0720;
LastUpgradeCheck = 1010;
ORGANIZATIONNAME = Allen;
TargetAttributes = {
9F3052081C5A700E008C3D51 = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = F3YT8BWBYJ;
LastSwiftMigration = 1010;
};
9F30521C1C5A700E008C3D51 = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = F3YT8BWBYJ;
LastSwiftMigration = 1010;
TestTargetID = 9F3052081C5A700E008C3D51;
};
9F3052271C5A700E008C3D51 = {
CreatedOnToolsVersion = 7.2;
DevelopmentTeam = F3YT8BWBYJ;
LastSwiftMigration = 1010;
TestTargetID = 9F3052081C5A700E008C3D51;
};
};
Expand Down Expand Up @@ -332,13 +338,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand Down Expand Up @@ -376,13 +392,23 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
Expand All @@ -401,6 +427,7 @@
IPHONEOS_DEPLOYMENT_TARGET = 9.2;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_COMPILATION_MODE = wholemodule;
VALIDATE_PRODUCT = YES;
};
name = Release;
Expand All @@ -409,32 +436,38 @@
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = 3DTouchQuickAction/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.appkitchen.-DTouchQuickAction";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Debug;
};
9F3052331C5A700E008C3D51 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = 3DTouchQuickAction/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.appkitchen.-DTouchQuickAction";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
};
name = Release;
};
9F3052351C5A700E008C3D51 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = 3DTouchQuickActionTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.appkitchen.-DTouchQuickActionTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/3DTouchQuickAction.app/3DTouchQuickAction";
};
name = Debug;
Expand All @@ -443,21 +476,25 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = 3DTouchQuickActionTests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.appkitchen.-DTouchQuickActionTests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/3DTouchQuickAction.app/3DTouchQuickAction";
};
name = Release;
};
9F3052381C5A700E008C3D51 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = 3DTouchQuickActionUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.appkitchen.-DTouchQuickActionUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TEST_TARGET_NAME = 3DTouchQuickAction;
USES_XCTRUNNER = YES;
};
Expand All @@ -466,10 +503,12 @@
9F3052391C5A700E008C3D51 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
DEVELOPMENT_TEAM = F3YT8BWBYJ;
INFOPLIST_FILE = 3DTouchQuickActionUITests/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "me.appkitchen.-DTouchQuickActionUITests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
TEST_TARGET_NAME = 3DTouchQuickAction;
USES_XCTRUNNER = YES;
};
Expand All @@ -494,6 +533,7 @@
9F3052331C5A700E008C3D51 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9F3052341C5A700E008C3D51 /* Build configuration list for PBXNativeTarget "3DTouchQuickActionTests" */ = {
isa = XCConfigurationList;
Expand All @@ -502,6 +542,7 @@
9F3052361C5A700E008C3D51 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9F3052371C5A700E008C3D51 /* Build configuration list for PBXNativeTarget "3DTouchQuickActionUITests" */ = {
isa = XCConfigurationList;
Expand All @@ -510,6 +551,7 @@
9F3052391C5A700E008C3D51 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
/* End XCConfigurationList section */
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
Original file line number Diff line number Diff line change
Expand Up @@ -18,102 +18,75 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
case Third

init?(fullType: String) {
guard let last = fullType.componentsSeparatedByString(".").last else { return nil }

guard let last = fullType.components(separatedBy: ".").last else {
return nil
}
self.init(rawValue: last)
}

var type: String {
return NSBundle.mainBundle().bundleIdentifier! + ".\(self.rawValue)"
return Bundle.main.bundleIdentifier! + ".\(self.rawValue)"
}

}

var window: UIWindow?

var launchedShortcutItem: UIApplicationShortcutItem?


func handleShortCutItem(shortcutItem: UIApplicationShortcutItem) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
return true
}

func application(_ application: UIApplication, performActionFor shortcutItem: UIApplicationShortcutItem, completionHandler: @escaping (Bool) -> Void) {
let handledShortCutItem = handleShortCutItem(shortcutItem)
completionHandler(handledShortCutItem)
}

// MARK:处理shortCutItem
func handleShortCutItem(_ shortcutItem: UIApplicationShortcutItem) -> Bool {

var handled = false

guard ShortcutIdentifier(fullType: shortcutItem.type) != nil else { return false }
guard let _ = ShortcutIdentifier(fullType: shortcutItem.type) else {
return false
}

guard let shortCutType = shortcutItem.type as String? else { return false }
guard let shortCutType = shortcutItem.type as String? else {
return false
}

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

switch (shortCutType) {
case ShortcutIdentifier.First.type:
// Handle shortcut 1
vc = storyboard.instantiateViewControllerWithIdentifier("RunVC") as! RunViewController
vc = storyboard.instantiateViewController(withIdentifier: "RunVC") as! RunViewController
handled = true
break
case ShortcutIdentifier.Second.type:
// Handle shortcut 2
vc = storyboard.instantiateViewControllerWithIdentifier("ScanVC") as! ScanViewController
vc = storyboard.instantiateViewController(withIdentifier: "ScanVC") as! ScanViewController
handled = true
break
case ShortcutIdentifier.Third.type:
// Handle shortcut 3
vc = storyboard.instantiateViewControllerWithIdentifier("WiFiVC") as! SwitchWiFiViewController
vc = storyboard.instantiateViewController(withIdentifier: "WiFiVC") as! SwitchWiFiViewController
handled = true
break
default:
vc = UIViewController()
break
}

// Display the selected view controller
window!.rootViewController?.presentViewController(vc, animated: true, completion: nil)

return handled

}

func application(application: UIApplication, performActionForShortcutItem shortcutItem: UIApplicationShortcutItem, completionHandler: (Bool) -> Void) {

let handledShortCutItem = handleShortCutItem(shortcutItem)
completionHandler(handledShortCutItem)
}

func applicationDidBecomeActive(application: UIApplication) {
guard let shortcut = launchedShortcutItem else { return }

handleShortCutItem(shortcut)
launchedShortcutItem = nil

}

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

if let shortcutItem = launchOptions?[UIApplicationLaunchOptionsShortcutItemKey] as? UIApplicationShortcutItem {
launchedShortcutItem = shortcutItem
//
var presentedVC: UIViewController = window!.rootViewController!
while presentedVC.presentedViewController != nil {
presentedVC = presentedVC.presentedViewController!
}
if !presentedVC.isMember(of: vc.classForCoder) {
presentedVC.present(vc, animated: true, completion: nil)
}

return true
}

func applicationWillResignActive(application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}


func applicationWillTerminate(application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
return handled
}


}

Loading

0 comments on commit 7e6387f

Please sign in to comment.