remove a button from application at runtime - xcode

I have a xcode/ipad application that adds buttons at runtime at the touch point on the screen.
Now I need to remove these button(s) at runtime by only using the x/y coordinates.
How do I accomplish this??
take care
tony

not the best and fastest way to do it, but iterate over the parent view's control list, find out their relative x/y coordinates and remove them from the parent view

Related

How to add a background image

I have a Image View on my storyboard, and when I am trying to use it as a background. No matter what I do, it always stays on top. How would I change it so that it would be a background image, I don't care weather I do it programmatically through swift or through another way.
In the Xcode Interface Builder, you can adjust which views are in the front by selecting the view and going to Editor -> Arrange -> Send to Front, Back, etc.
This can also be done programmatically using UIView methods like bringSubviewToFront:
By moving any of item up/down you can set their layer state. The first one will be on back then second will appear on the first one then.... last one will appear on top most.
I hope this will help you.
If you decide to do it programmatically, you can modify the zPosition property of the view:
myImageView.layer.zPosition = 1
Higher numbers are closer to your face, lower numbers are closer to the screen. So to set your image view as a background, make sure the other views have higher z-positions than it.

How to hide outer bounded parent rectangle in GEF figure

I am trying to create a circle or an ellipse in GEF framework. We are setting constraints/bounds as a rectangle within which the circle/ellipse sits.
My problem is that I am not able to hide/suppress outer Rectangle when I do drag drop or I just click on the circle. Is there any way we can remove this outer Rectangle ? any tip idea would help. thanks
This rectangle is created by the NonResizableEditPolicy (or ResizableEditPolicy if your figure is resizable). This policy is added automatically to children of some layout policies, for example children of ConstrainedLayoutEditPolicy. What you need to do is find which layout policy you are using in your container, and override it to use a different edit policy to decorate the children of the container. This can be done by overriding the NonResizableEditPolicy (or ResizableEditPolicy) and then modify how this policy provides feedback when the Figure is selected, clicked on, etc.

Drag and Drop functionality using testcomplete

I want to simulate a drag and drop functionality from one DevXtraGridcell to another DevXtraGridcell without using the coordinate system.
Can someone give me an idea how can I do it without the default record and play and without the source and destination cordinates.
The Drag action always uses coordinates, but you can calculate the coordinates on the fly instead of using hard-coded coordinates:
Explore your grid in TestComplete's Object Browser and find a method or property that returns cell coordinates.
According to this old blog post, it should be something like:
gridObj.MainView.ViewInfo.RowsInfo.GetInfoByHandle(Row).Cells.Item_2(Column).Bounds
Calculate the coordinates of the first and second cell. (Make sure that both cells are visible on the screen.)
Do the Drag from one first cell's coordiantes to the second cell's coordinates.
in my case i had to user the obj.MainView.get_ViewInfo property worked for one gridcontrol , the other is of card layout the link given doesnt work in my case though

Drawing on an image which is inside a QScrollArea?

If I subclass QLabel and I add a QLabel directly to my QDialog, it works fine. If I add this label inside a ScrollArea, the thing I’m drawing doesn’t show unless I resize the dialog itself. Yes, weird.
I’ve setup compilable example code that indicates what the problem is. What I am trying to do is to select an area of an image with my mouse, by drawing a rectangle on the corresponding area. The images my program is designed to work with can be very large, and thus, I need to have a scroll area so as the dialog to stay at a logical dimension, and not to fill the entire screen (or even multiple workspaces, if we are talking about a linux machine with multiple desktops).
Everything works fine, except that the drawing (selection-rectangle) isn’t visible unless the dialog is resized – manually. I think I have to update something while drawing, but I’m not sure what. Well, here’s the example code: http://paste.ubuntu.com/1151553/
Another issues that I don’t know how to solve (and I want your suggestions there) are (1) when the user is selecting an area, how to set it to automatically scroll when the user actually selects an area by pushing against to a wall of the scroll area (I guess I am understandable here). (2) is there a way to let the user select a rectangle and then, when he left-clicks on a position with holding down the [Shift] button, the bottom right edge of his previous selection to actually go through the point he clicks at?
The documentation indicates that you have to set a Layout somehow somewhere, but I'm not sure how to do this to my occassion.
Thanks in advance for any help.
about problem (1):
just use of Event. i think mouse Enter Event or Leave Event is good for that.
and to do that i think you can use a hidden rectangular that fill the whole of the screen.
and over write the mouse leave Event for that rectangular and tell in that function , to scroll the page.

How to find coordinates of mouse cursor in interface builder

I want to know exactly where I am placing my images programatically, and therefore need to know the coordinates of my storyboard.
Is there a way to view these from the interface builder in Xcode?
Your workspace dimension is 320X460 suppose you want to add a button programmatically first go into IB and place a button where you want it to be and then in the right side check the coordinates of button in show the size inspector and use those coordinates in your code this will give you a fair idea about where your button will go after you add it programmatically... hope this will help you
NO. Use your imagination. Programmatically added visual objects cannot be seen in IB.
Instead, you could place an object in IB, adjust it's position to the desired one, read it's frame, delete it from IB, and use it's frame values to programmatically add id.

Resources