Touches not coming to scaled UIView
So:
- I create a view that is bigger than parent view and the screen (view is added and the frame is set)
- I apply scale transform, so that this view fits the screen and bounds of parent view
- The parts that was previously out of bounds of the parent view don't receive touch events
Any idea how to make this working?
See also questions close to this topic
-
CALayer: create broken ellipse with round edges?
Here is my code to add an elliptic
CALayer
to aUIView
:let circleLayer = CAShapeLayer() circleLayer.path = UIBezierPath(arcCenter: CGPoint(x: frame.size.width / 2, y: frame.size.height / 2), radius: frame.size.width / 2, startAngle: -.pi / 2, endAngle: .pi / 6, clockwise: false).cgPath circleLayer.lineWidth = 8.0 circleLayer.cornerRadius = 4.0 circleLayer.strokeColor = UIColor.black.cgColor circleLayer.fillColor = UIColor.clear.cgColor circleLayer.lineJoin = .round squareView.layer.backgroundColor = UIColor.clear.cgColor squareView.layer.addSublayer(circleLayer)
The result I get :
However, I would like to get this result instead:
Could you help me getting this?
Thank you for your help!
-
Simulator not showing in Spotlight search - Big Sur
Hopefully a straight forward one here, but my Simulator app (Xcode IOS Simulator) is not being found through Spotlight search on Mac. I recently upgraded to Big Sur and I am currently using 11.1.
Just wondering if anyone is having the same problem. I am able to access Simulator through other methods but it just doesn't seem to be indexed in the Spotlight search. Cheers
-
Flutter app is quitting on physical iOS device
Recently upgraded to flutter version 1.22.5 & testing my flutter app on my IOS device (14.3).
The app launched perfectly on the IOS simulator but not on my physical device.
Whenever im launching the app I get :
Error connecting to the service protocol: failed to connect to http://127.0.0.1:59046/wJX8XWG3jDg=/
I implemented :
The solution of unchecking "Disable unless needed" in the System Preferences as suggested by https://github.com/flutter/flutter/issues/46705#issuecomment-566813481
I tried to disable my firewall & to restart my device
I tried to unplug-plug my device cable again and to turn on-off the wifi (its private) as suggested by some
I deleted derived data from Xcode and cleaned the build folder
None of these solutions worked.
This is my flutter doctor -v response:
[✓] Flutter (Channel stable, 1.22.5, on Mac OS X 10.15.6 19G2021 darwin-x64, locale en-LB) • Flutter version 1.22.5 at /Users/mac/FlutterSDK/flutter • Framework revision 7891006299 (6 weeks ago), 2020-12-10 11:54:40 -0800 • Engine revision ae90085a84 • Dart version 2.10.4 [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/mac/Library/Android/sdk • Platform android-30, build-tools 30.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 12.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.1, Build version 12A7403 • CocoaPods version 1.10.0 [✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin installed • Dart plugin version 201.9317 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [!] VS Code (version 1.51.1) • VS Code at /Applications/Visual Studio Code.app/Contents ✗ Flutter extension not installed; install from https://marketplace.visualstudio.com/items?itemName=Dart-Code.flutter [✓] Connected device (2 available) • iPhone (mobile) • 6c0132c487f1e05eadb519904911b8033debc9ba • ios • iOS 14.3 • iPhone 11 Pro Max (mobile) • B01DE645-7151-49F5-A445-21A9C0073E9D • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator) ! Doctor found issues in 1 category.
and this what
flutter run --verbose
ends with:[ ] Starting debug of 6c0132c487f1e05eadb519904911b8033debc9ba (D221AP, iPhone X, iphoneos, arm64) a.k.a. 'iPhone' connected through USB... [ +163 ms] [ 0%] Looking up developer disk image [ +13 ms] [ 95%] Developer disk image mounted successfully [ +985 ms] [100%] Connecting to remote debug server [ ] ------------------------- [ +615 ms] (lldb) command source -s 0 '/tmp/F0A6301B-AE37-40D0-9169-6B4B25988D2C/fruitstrap-lldb-prep-cmds-6c0132c487f1e05eadb519904911b8033debc9ba' [ ] Executing commands in '/tmp/F0A6301B-AE37-40D0-9169-6B4B25988D2C/fruitstrap-lldb-prep-cmds-6c0132c487f1e05eadb519904911b8033debc9ba'. [ ] (lldb) platform select remote-ios --sysroot '/Users/mac/Library/Developer/Xcode/iOS DeviceSupport/14.3 (18C66)/Symbols' [ ] Platform: remote-ios [ ] Connected: no [ ] SDK Path: "/Users/mac/Library/Developer/Xcode/iOS DeviceSupport/14.3 (18C66)/Symbols" [ ] (lldb) target create "/Users/mac/Desktop/AuxiPI/PI_Flutter_App/build/ios/iphoneos/Runner.app" [+2077 ms] Current executable set to '/Users/mac/Desktop/AuxiPI/PI_Flutter_App/build/ios/iphoneos/Runner.app' (arm64). [ ] (lldb) script fruitstrap_device_app="/private/var/containers/Bundle/Application/41BF75B2-FAB0-472E-B50A-B7AC6A77493A/Runner.app" [ +9 ms] (lldb) script fruitstrap_connect_url="connect://127.0.0.1:49950" [ +3 ms] (lldb) script fruitstrap_output_path="" [ +1 ms] (lldb) script fruitstrap_error_path="" [ +3 ms] (lldb) target modules search-paths add /usr "/Users/mac/Library/Developer/Xcode/iOS DeviceSupport/14.3 (18C66)/Symbols/usr" /System "/Users/mac/Library/Developer/Xcode/iOS DeviceSupport/14.3 (18C66)/Symbols/System" "/private/var/containers/Bundle/Application/41BF75B2-FAB0-472E-B50A-B7AC6A77493A" "/Users/mac/Desktop/AuxiPI/PI_Flutter_App/build/ios/iphoneos" "/var/containers/Bundle/Application/41BF75B2-FAB0-472E-B50A-B7AC6A77493A" "/Users/mac/Desktop/AuxiPI/PI_Flutter_App/build/ios/iphoneos" /Developer "/Users/mac/Library/Developer/Xcode/iOS DeviceSupport/14.3 (18C66)/Symbols/Developer" [ +79 ms] (lldb) command script import "/tmp/F0A6301B-AE37-40D0-9169-6B4B25988D2C/fruitstrap_6c0132c487f1e05eadb519904911b8033debc9ba.py" [ +6 ms] (lldb) command script add -f fruitstrap_6c0132c487f1e05eadb519904911b8033debc9ba.connect_command connect [ ] (lldb) command script add -s asynchronous -f fruitstrap_6c0132c487f1e05eadb519904911b8033debc9ba.run_command run [ ] (lldb) command script add -s asynchronous -f fruitstrap_6c0132c487f1e05eadb519904911b8033debc9ba.autoexit_command autoexit [ ] (lldb) command script add -s asynchronous -f fruitstrap_6c0132c487f1e05eadb519904911b8033debc9ba.safequit_command safequit [ ] (lldb) connect [ +47 ms] (lldb) run [ +337 ms] success [ ] (lldb) safequit [ +132 ms] Process 978 detached [ +19 ms] Application launched on the device. Waiting for observatory port. [ +25 ms] Attempting to forward device port 57290 to host port 49957 [ +1 ms] executing: /Users/mac/FlutterSDK/flutter/bin/cache/artifacts/usbmuxd/iproxy 49957:57290 --udid 6c0132c487f1e05eadb519904911b8033debc9ba [+1011 ms] Forwarded port ForwardedPort HOST:49957 to DEVICE:57290 [+2224 ms] HttpException: , uri = http://localhost:49957/ws [+2012 ms] HttpException: , uri = http://localhost:49957/ws [+2006 ms] HttpException: , uri = http://localhost:49957/ws [+2014 ms] HttpException: , uri = http://localhost:49957/ws [+2008 ms] Failed to connect directly, falling back to mDNS [ +11 ms] Checking for advertised Dart observatories... [+5039 ms] Checking for available port on com.auxi.ai._dartobservatory._tcp.local [ +2 ms] Checking for authentication code for com.auxi.ai._dartobservatory._tcp.local [ +4 ms] Attempting to forward device port 55983 to host port 49989 [ ] executing: /Users/mac/FlutterSDK/flutter/bin/cache/artifacts/usbmuxd/iproxy 49989:55983 --udid 6c0132c487f1e05eadb519904911b8033debc9ba [+1005 ms] Forwarded port ForwardedPort HOST:49989 to DEVICE:55983 [ +2 ms] Installing and launching... (completed in 45.2s) [ +1 ms] Caching compiled dill [ +239 ms] Connecting to service protocol: http://127.0.0.1:49989/wJX8XWG3jDg=/ [ +1 ms] DDS is currently disabled due to https://github.com/flutter/flutter/issues/62507 [ +12 ms] Fail to connect to service protocol: http://127.0.0.1:49989/wJX8XWG3jDg=/: HttpException: , uri = http://127.0.0.1:49989/wJX8XWG3jDg=/ws [ +1 ms] Error connecting to the service protocol: failed to connect to http://127.0.0.1:49989/wJX8XWG3jDg=/ [ +4 ms] "flutter run" took 295,502ms. [ +6 ms] #0 throwToolExit (package:flutter_tools/src/base/common.dart:14:3) #1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:607:7) <asynchronous suspension> #2 FlutterCommand.verifyThenRunCommand (package:flutter_tools/src/runner/flutter_command.dart:977:18) #3 _rootRunUnary (dart:async/zone.dart:1198:47) #4 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #5 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #6 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #7 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #8 Future._completeWithValue (dart:async/future_impl.dart:529:5) #9 _AsyncAwaitCompleter.complete (dart:async-patch/async_patch.dart:40:15) #10 _completeOnAsyncReturn (dart:async-patch/async_patch.dart:311:13) #11 RunCommand.usageValues (package:flutter_tools/src/commands/run.dart) #12 _rootRunUnary (dart:async/zone.dart:1198:47) #13 _CustomZone.runUnary (dart:async/zone.dart:1100:19) #14 _FutureListener.handleValue (dart:async/future_impl.dart:143:18) #15 Future._propagateToListeners.handleValueCallback (dart:async/future_impl.dart:696:45) #16 Future._propagateToListeners (dart:async/future_impl.dart:725:32) #17 Future._completeWithValue (dart:async/future_impl.dart:529:5) #18 Future._asyncCompleteWithValue.<anonymous closure> (dart:async/future_impl.dart:567:7) #19 _rootRun (dart:async/zone.dart:1190:13) #20 _CustomZone.run (dart:async/zone.dart:1093:19) #21 _CustomZone.runGuarded (dart:async/zone.dart:997:7) #22 _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1037:23) #23 _microtaskLoop (dart:async/schedule_microtask.dart:41:21) #24 _startMicrotaskLoop (dart:async/schedule_microtask.dart:50:5) #25 _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:118:13) #26 _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:169:5) [ +306 ms] ensureAnalyticsSent: 253ms [ +2 ms] Running shutdown hooks [ +1 ms] Shutdown hook priority 4 [ +8 ms] Shutdown hooks complete [ ] exiting with code 2
-
UIView: how to rounded borders of subview in view?
I would like to get this result:
I tried this in my view controller:
override func viewDidLoad() { roundView.layer.cornerRadius = 10.0 let blueView = UIView(frame: CGRect(origin: .zero, size: CGSize(width: 5, height: roundView.bounds.height))) blueView.backgroundColor = .blue blueView.clipsToBounds = true roundView.addSubview(blueView) }
But I'm getting this result:
How can I achieve this result?
Thank you for your help
-
Send data changes from UIKit, Wrapped inside UIViewRepresentable, to SwiftUI, and Rich Text Editor problem
I am working on a SwiftUI project, the functionalities it required is to make a Rich Text Editor on IOS.
The approach I am following is fairly simple, I used cbess/RichTextEditor link originally written in UIKit and import it into SwiftUI. To run the imported UIView, I wrap the view inside one UIViewRpresentable and add it into the ContentView struct of SwiftUI.
Now, I want to publish the data inside UIView and assign it to one of @state ContentView owns.
The code structure look similar to this:
For the ContentView (SwiftUI)
struct ContentView: View { @State var textHtml: String = "" //I want all changes come from UIView be stored inside this var body: some View { VStack { Cbess( frameEditor: CGRect(x: 0, y: 40, width: 360, height: 400) ) } } }
For the UiViewRepresentable
struct Cbess : UIViewRepresentable{ let frameEditor : CGRect func makeUIView(context: Context) -> UIView { let frameEditor = RichEditorView(frame: frameEditor) let uiView : UIView = UIView() uiView.addSubview(editorView) return uiView } func updateUIView(_ uiView: UIView, context: Context) { } }
For the UiView(Simplified)
@objcMembers open class RichEditorView: UIView, { var contentHTML : String // This variable get updated regularly }
One additional question is that I want to make a Rich Text Editor by solely SwiftUI. How can I achieve it? Can you give me some keywords? Some Repo?
Any help is very appreciated! Thanks for read this whole question.
-
In UiButton ImageView.alpha is changed after click event, how to keep previous alpha?
I have a UIButton with image (default imageView for UIButton).
After creation and layout i set:
button.imageView?.alpha = 0.3
and everything works.
But after button tap action, picture is fully visible again, and aplha value is changed.
Hot to prevent it, to have the same aplha value after button tapped action?
-
Dragging a player on screen using touch
I am new to android development, and I am looking for the best method to drag an object (in my case- the player) on screen, in a game. I have not seen any recent best practices for that in this site that is different than this (looked thoroughly!). I need to take into consideration collisions as well, but haven't implemented that yet. My current implementation is as follows:
alien = findViewById(R.id.alien); alien.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { int imageWidth = v.getLayoutParams().width; int imageHeight = v.getLayoutParams().height; switch (event.getAction()) { case MotionEvent.ACTION_DOWN: m_X = v.getX() - event.getRawX(); m_Y = v.getY() - event.getRawY(); return true; case MotionEvent.ACTION_MOVE: if (imageWidth == screenWidth) { } else { v.animate().x(event.getRawX() + m_X).y(event.getRawY() + m_Y).setDuration(0).start(); } if (event.getRawX() + m_X + imageWidth > screenWidth) { v.animate().x(screenWidth - imageWidth).setDuration(0).start(); } if (event.getRawX() + m_X < 0) { v.animate().x(0).setDuration(0).start(); } if (event.getRawY() + m_Y + imageHeight > screenHeight) { v.animate().y(screenHeight - imageHeight).setDuration(0).start(); } if (event.getRawY() + m_Y < 0) { v.animate().y(0).setDuration(0).start(); } } return true; } });
m_X
is the x position of the image view.m_Y
is the y position of the image view.This implementation passes the test, I can move the alien image view around the screen with my finger, without any visual bugs. But I was wondering if this implementation is good / wrong. I've read that I would have problems implementing collisions with this code, and the best practice would be using a surface view / canvas, but couldn't find any reading materials on that. Is there a way to achieve the same results with a Surface View or using a canvas, or something else? Also, for some reason I cannot understand, once I move this code outside of this class, to a different class (I want the player to be in a class of it's own), the touch event is not registered.
-
The touch () command in Linux is asking for an input. What are we supposed to type in there?
I was playing around with the
touch
command and as I entered thetouch ()
command, I expected either an error or a new empty file named()
. Instead, I got thistouch () >
and it expects me to enter something.
What is thistouch ()
command doing? What is it for? -
JavaFX - Pannable ListView
I have noticed that ListView does not behave the same as ScrollPane in terms of scrolling on Embedded Devices with touch. I cannot find a way to make ListView pannable, so as to make it scroll when dragging, and bounce back when off bounds (see example).
You can simulate touching by setting the JVM arguments below.
-Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.touch=true
public class ScrollTouch extends Application { @Override public void start(Stage primaryStage) throws Exception { primaryStage.setTitle("ScrollBar VS ListView"); // ScrollPane ScrollPane scrollPane = new ScrollPane(); VBox spContent = new VBox(); for(int i=0; i<20; i++) spContent.getChildren().add(getLabel("Label No." + i)); scrollPane.setPrefWidth(150); scrollPane.setContent(spContent); scrollPane.setPannable(true); // ListView ListView<Label> listView = new ListView<Label>(); for(int i=0; i<20; i++) listView.getItems().add(getLabel("Label No." + i)); listView.setFocusTraversable(false); HBox rootPane = new HBox(); rootPane.getChildren().addAll(scrollPane,listView); Scene scene = new Scene(rootPane, 400, 300); primaryStage.setScene(scene); primaryStage.show(); } private Label getLabel(String text) { Label label = new Label(text); label.setPrefHeight(20); return label; } public static void main(String[] args) { Application.launch(args); } }