custom UIApp to fix missing touch event
parent
a5e9598f66
commit
154ce52c30
|
@ -13,7 +13,7 @@
|
|||
1968E72E24086C2B00784829 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1968E72D24086C2B00784829 /* Assets.xcassets */; };
|
||||
1968E73424086C2B00784829 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 1968E73324086C2B00784829 /* main.m */; };
|
||||
19F13E2A240A6F2200809B83 /* SocketDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 19F13E29240A6F2200809B83 /* SocketDelegate.m */; };
|
||||
19F13E2C240CDE4000809B83 /* MainView.m in Sources */ = {isa = PBXBuildFile; fileRef = 19F13E2B240CDE3F00809B83 /* MainView.m */; };
|
||||
19F4071A240CFCFF00D7F506 /* MainApp.m in Sources */ = {isa = PBXBuildFile; fileRef = 19F40719240CFCFF00D7F506 /* MainApp.m */; };
|
||||
D023549DD3B09C46EBA2E321 /* libPods-Brokenithm-iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5A7EE02147010843456A2152 /* libPods-Brokenithm-iOS.a */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
|
@ -29,8 +29,8 @@
|
|||
1968E73324086C2B00784829 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
|
||||
19F13E22240A683200809B83 /* SocketDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SocketDelegate.h; sourceTree = "<group>"; };
|
||||
19F13E29240A6F2200809B83 /* SocketDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SocketDelegate.m; sourceTree = "<group>"; };
|
||||
19F13E2B240CDE3F00809B83 /* MainView.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MainView.m; sourceTree = "<group>"; };
|
||||
19F13E2D240CDF5400809B83 /* MainView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainView.h; sourceTree = "<group>"; };
|
||||
19F13E2E240CFC8900809B83 /* MainApp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MainApp.h; sourceTree = "<group>"; };
|
||||
19F40719240CFCFF00D7F506 /* MainApp.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MainApp.m; sourceTree = "<group>"; };
|
||||
259804D4CC006A58255BC938 /* Pods-Brokenithm-iOS.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Brokenithm-iOS.release.xcconfig"; path = "Pods/Target Support Files/Pods-Brokenithm-iOS/Pods-Brokenithm-iOS.release.xcconfig"; sourceTree = "<group>"; };
|
||||
5A7EE02147010843456A2152 /* libPods-Brokenithm-iOS.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Brokenithm-iOS.a"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
B78B36B35C6A90E4F71F84B4 /* Pods-Brokenithm-iOS.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Brokenithm-iOS.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Brokenithm-iOS/Pods-Brokenithm-iOS.debug.xcconfig"; sourceTree = "<group>"; };
|
||||
|
@ -71,8 +71,6 @@
|
|||
children = (
|
||||
1968E72424086C2200784829 /* AppDelegate.h */,
|
||||
1968E72524086C2200784829 /* AppDelegate.m */,
|
||||
19F13E2D240CDF5400809B83 /* MainView.h */,
|
||||
19F13E2B240CDE3F00809B83 /* MainView.m */,
|
||||
1968E72724086C2200784829 /* ViewController.h */,
|
||||
1968E72824086C2200784829 /* ViewController.m */,
|
||||
1968E72A24086C2200784829 /* Main.storyboard */,
|
||||
|
@ -81,6 +79,8 @@
|
|||
1968E73324086C2B00784829 /* main.m */,
|
||||
19F13E22240A683200809B83 /* SocketDelegate.h */,
|
||||
19F13E29240A6F2200809B83 /* SocketDelegate.m */,
|
||||
19F13E2E240CFC8900809B83 /* MainApp.h */,
|
||||
19F40719240CFCFF00D7F506 /* MainApp.m */,
|
||||
);
|
||||
path = "Brokenithm-iOS";
|
||||
sourceTree = "<group>";
|
||||
|
@ -193,10 +193,10 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
19F13E2C240CDE4000809B83 /* MainView.m in Sources */,
|
||||
1968E72924086C2200784829 /* ViewController.m in Sources */,
|
||||
1968E73424086C2B00784829 /* main.m in Sources */,
|
||||
1968E72624086C2200784829 /* AppDelegate.m in Sources */,
|
||||
19F4071A240CFCFF00D7F506 /* MainApp.m in Sources */,
|
||||
19F13E2A240A6F2200809B83 /* SocketDelegate.m in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
//
|
||||
|
||||
#import "AppDelegate.h"
|
||||
#import "MainApp.h"
|
||||
|
||||
@interface AppDelegate ()
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<viewControllerLayoutGuide type="top" id="26Q-bF-23b"/>
|
||||
<viewControllerLayoutGuide type="bottom" id="15f-bj-ZYr"/>
|
||||
</layoutGuides>
|
||||
<view key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="8bC-Xf-vdC" customClass="MainView">
|
||||
<view key="view" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" id="8bC-Xf-vdC">
|
||||
<rect key="frame" x="0.0" y="0.0" width="667" height="375"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// MainView.h
|
||||
// MainApp.h
|
||||
// Brokenithm-iOS
|
||||
//
|
||||
// Created by ester on 2020/3/2.
|
||||
|
@ -8,10 +8,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <UIKit/UIKit.h>
|
||||
#import "ViewController.h"
|
||||
|
||||
@interface MainView : UIView
|
||||
@property ViewController *parent;
|
||||
@interface MainApp : UIApplication
|
||||
@property ViewController *vc;
|
||||
@end
|
|
@ -0,0 +1,24 @@
|
|||
//
|
||||
// MainApp.m
|
||||
// Brokenithm-iOS
|
||||
//
|
||||
// Created by ester on 2020/3/2.
|
||||
// Copyright © 2020 esterTion. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "MainApp.h"
|
||||
|
||||
@interface MainApp ()
|
||||
@end
|
||||
|
||||
@implementation MainApp
|
||||
|
||||
-(void)sendEvent:(UIEvent *)event {
|
||||
if (event.type == UIEventTypeTouches) {
|
||||
[(ViewController*)self.keyWindow.rootViewController updateTouches:event];
|
||||
}
|
||||
[super sendEvent:event];
|
||||
}
|
||||
|
||||
@end
|
|
@ -1,29 +0,0 @@
|
|||
//
|
||||
// MainView.m
|
||||
// Brokenithm-iOS
|
||||
//
|
||||
// Created by ester on 2020/3/2.
|
||||
// Copyright © 2020 esterTion. All rights reserved.
|
||||
//
|
||||
|
||||
#import "MainView.h"
|
||||
|
||||
|
||||
@implementation MainView
|
||||
|
||||
-(id)init{
|
||||
id val = [super init];
|
||||
self.multipleTouchEnabled = YES;
|
||||
return val;
|
||||
}
|
||||
|
||||
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSLog(@"began"); [self updateTouches:event]; }
|
||||
-(void)touchesEnded:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSLog(@"ended"); [self updateTouches:event]; }
|
||||
-(void)touchesMoved:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSLog(@"moved"); [self updateTouches:event]; }
|
||||
-(void)touchesCancelled:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event { NSLog(@"cancel"); [self updateTouches:event]; }
|
||||
|
||||
-(void)updateTouches:(UIEvent *)event {
|
||||
[self.parent updateTouches:event];
|
||||
}
|
||||
|
||||
@end
|
|
@ -16,8 +16,6 @@
|
|||
|
||||
- (void)viewDidLoad {
|
||||
[super viewDidLoad];
|
||||
((MainView*)(self.view)).parent = self;
|
||||
self.view.multipleTouchEnabled = YES;
|
||||
|
||||
// network permission
|
||||
/*
|
||||
|
|
|
@ -11,6 +11,6 @@
|
|||
|
||||
int main(int argc, char * argv[]) {
|
||||
@autoreleasepool {
|
||||
return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
|
||||
return UIApplicationMain(argc, argv, @"MainApp", NSStringFromClass([AppDelegate class]));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue