Re: What is the best strategy for this?
On 3 Apr 2021, at 8:46 am, Ben Kennedy <ben-groups@...> wrote:On Apr 3, 2021, at 8:04 AM, Rick Aurbach via groups.io <rlaurb@...> wrote: This piqued my curiosity, so I couldn't help myself and built a test case. This seems to work perfectly -- and no collection view required. The code is short enough that I've copy/pasted it all below. -ben class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() let dimension = 4 let spacing = CGFloat(2.0) let containerStackView = UIStackView() containerStackView.axis = .vertical containerStackView.spacing = spacing containerStackView.alignment = .center containerStackView.distribution = .equalSpacing containerStackView.translatesAutoresizingMaskIntoConstraints = false view.addSubview(containerStackView) NSLayoutConstraint.activate([ containerStackView.centerXAnchor.constraint(equalTo: view.centerXAnchor), containerStackView.centerYAnchor.constraint(equalTo: view.centerYAnchor), ]) for y in 1...(dimension * 2) { let rowStackView = UIStackView() rowStackView.axis = .horizontal rowStackView.spacing = spacing rowStackView.alignment = .center rowStackView.distribution = .equalSpacing rowStackView.translatesAutoresizingMaskIntoConstraints = false containerStackView.addArrangedSubview(rowStackView) for _ in 1...(y <= dimension ? y * 2 - 1 : (dimension * 2 - y + 1) * 2 - 1) { let cubbyHoleView = CubbyHoleView() cubbyHoleView.translatesAutoresizingMaskIntoConstraints = false rowStackView.addArrangedSubview(cubbyHoleView) NSLayoutConstraint.activate([ cubbyHoleView.widthAnchor.constraint(equalTo: view.widthAnchor, multiplier: 0.5 / CGFloat(dimension)), cubbyHoleView.heightAnchor.constraint(equalTo: cubbyHoleView.widthAnchor) ]) } } containerStackView.transform = CGAffineTransform.init(rotationAngle: -45.0 * CGFloat.pi / 180.0) } } class CubbyHoleView: UIView { let defaultBackgroundColor = UIColor.systemBlue.withAlphaComponent(0.1) init() { super.init(frame: .zero) backgroundColor = defaultBackgroundColor layer.borderColor = UIColor.black.cgColor layer.borderWidth = 2.0 } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) { backgroundColor = .systemYellow } override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) { backgroundColor = defaultBackgroundColor } }
|
|
Re: What is the best strategy for this?
On Apr 3, 2021, at 8:04 AM, Rick Aurbach via groups.io <rlaurb=me.com@groups.io> wrote:Yes, so why not transform the collection view as a whole (not the cells)? -ben
|
|
Re: What is the best strategy for this?
Alex Zavatone
It would be interesting to try out. Try removing the spaces between each cell and issue the rotation, then try it out and find out.
toggle quoted messageShow quoted text
Alex Zavatone
|
|
Re: What is the best strategy for this?
It's an interesting idea, but there's an added complication (which I apologize for not making explicit in the original post) which makes this problematic. Each of these objects is a cell in a UICollectionView (with a custom Layout). I rather fear that without overriding pieces of touch processing, the collection view will not treat the rotated cell geometry properly.
Another way of thinking of this problem is as trying to create a non-rectangular collection-view cell which responds based on its shape, not its bounding box.
|
|
Re: What is the best strategy for this?
On 2 Apr 2021, at 3:27 pm, Rick Aurbach via groups.io <rlaurb=me.com@groups.io> wrote:Perhaps this is naïve, but the first thing that comes to mind: could you not simply deal with it as a regular matrix of squares, and then apply a 45 degree transform on the view? (I haven't tested anything like this, but I presume that touch events would be transformed accordingly…?) -ben
|
|
What is the best strategy for this?
Problem: I am designing a collection view with overlapping cells. Each cell has an active area inside it (and the active areas of adjacent cells do not overlap). (More information about what I'm doing at the bottom of this post.) I want a tap in the active area of a cell to select that cell, but a tap outside the active area of any cell should deselect the currently selected cell [single selection only; I don't need to support multi-selection at this point].
My original thought was to override the collection view's indexPathForItem(at:) and either the cell's touch event handlers or UICollectionView's touch event handlers. But, to make this work, I also need to know something about HOW the touch event handler interact with the UICollectionView. (This might be as simple as having touchesEnded(_:with:) call selectItem(at:animated:scrollPosition:) and deselectItem(at:animated:). Or?) Before I start possibly reinventing the wheel here, I'd like to ask if anyone has done anything similar and has any ideas to share. Thanks, Rick ------------------------- Consider a square cell which contains a diamond. The four vertices of the diamond are the midpoints of the four sides of the cell. The active region of each cell is the area inside the diamond. Cells are close-packed horizontally. Each section (i.e., "row") is offset a half-width down and a half-width to the side of the cells above it. In other words, the cells are positioned so that the diamond edges are superimposed. The attached image should give you an idea.
|
|
Re: Compiler error - method not found on object which conforms to protocol
Sandor Szatmari
Alex,
Thanks for your input. On Mar 30, 2021, at 10:13, Alex Zavatone via groups.io <zav@...> wrote: Yes, the conforming class did have the method/property implemented. Yes the compiler warns if the conforming class does not fully implement the protocol. And of course there are required and optional aspects to a protocol. The compiler only warns about required elements that are missing.
The object was already declared as conformant @property (readonly) id<DataSrcProto> dataSource; But, without the actual import in the scope of the compilation unit, the compiler had no idea what methods were actually declared in the protocol. Thanks, Sandor
|
|
Re: Compiler error - method not found on object which conforms to protocol
Alex Zavatone
Hi. I’m late to the discussion, but have you put the property or method on the class?
toggle quoted messageShow quoted text
When you have a class that conforms to a protocol, my understanding is that you cross your heart and swear to die that you will make sure that the class doing the conforming will implement those methods/properties. I’m not sure if this would work with inherited methods or properties as I’ve never tried it. Now, if a method missing for a property (if it is implemented), I’d expect it would be accessor methods. If your conforming class has the property declared, try creating the set and bet methods. If the property isn’t declared, try declaring it and I’d expect Objectice-C to auto declare the accessors. If it doesn’t, then add them to see if the error goes away. Best of luck, Alex Zavatone
|
|
Re: Compiler error - method not found on object which conforms to protocol
Sandor Szatmari
Thanks for everyone’s help and I’m sorry I was unable to share the code. I’m sure it would have been obvious and everyone would have see the issue with the actual code available.
toggle quoted messageShow quoted text
It turns out that I only had a forward declaration of the protocol in the header, once I added an actual import of the protocol to the ‘.m’ file, the error was resolved. Thanks again for everyone’s thoughts! Sandor
On Mar 27, 2021, at 12:39, Sak Wathanasin <sw@...> wrote:
|
|
Re: Compiler error - method not found on object which conforms to protocol
Sak Wathanasin
As Allan suggested, maybe you should post the actual code. I have this same usage in my code and it builds & runs just fine. Regards Sak
|
|
Re: Trouble with NSTableViews in macOS 11.x
Sak Wathanasin
Both "plain" and "fullwidth" sort of work; my mistake was using IB to set this property and it had no effect. When I set it in code (thanks, Shane!), I could see differences in behaviour. Both styles result in the gridlines being drawn from edge to edge. However, 1) with "fullwidth" - the table is still indented (6 or 16 px as before) - if the enclosing scrollview has borders, gridlines are drawn for empty rows - if the scrollview has no borders, gridlines are not drawn for empty rows 2) with "plain" - the table is no longer indented - gridlines are not drawn for empty rows whether the scrollview has borders or not We want gridlines on empty rows, but our tables are also borderless as the designers wanted the border around the table name label as well. Bascially, we want the 10.15 behaviour back. That it behaves differently depending on whether the enclosing scrollview is bordered or not doesn't feel right. I guess it's worth raising a bug report with Apple and seeing what comes of it. Thanks to everyone Sak
|
|
Re: Compiler error - method not found on object which conforms to protocol
Allan Odgaard
On 27 Mar 2021, at 2:41, Sandor Szatmari wrote:
There is nothing conceptually wrong with what you sketch in your pseudo-code. Please post an actual runnable example, as your pseudo-code has typos and lack context, something like the below compiles (and runs) just fine:
|
|
Re: Compiler error - method not found on object which conforms to protocol
Sandor Szatmari
Thanks Sak,
On Mar 27, 2021, at 04:54, Sak Wathanasin <sw@...> wrote:
Port = (NSUInteger)[self.dataSource serverPort]; This succeeds at runtime, but of course smells, and doesn’t squelch the warning.
Thanks, Sandor
|
|
Re: Compiler error - method not found on object which conforms to protocol
Sak Wathanasin
-(NSUinteger)serverPort; serverPort isn't a property, so you have to use [self.dataSource serverPort]; If you want it to be a property, make it so @protocol dataSrcProto @property (readonly) NSUinteger serverPort; @end Regards Sak
|
|
Compiler error - method not found on object which conforms to protocol
Sandor Szatmari
I have a server class which is abstracted to receive it’s final configuration from it’s data source. The idea is you instantiate the server set the data source and then start the server. During startup the server reads some configuration, such as the port to start on, from the data source. This is outlined in pseudocode below. This is mostly working except for a compiler error I can’t explain. The compiler issues an error about accessing the port from the data source.
Port = self.dataSource.serverPort; It says “Property ‘-serverPort’ not found on object of type ‘id<dataSrcProto>’” Anyone come across this? ——— server.h/m ———- @class server @property (readwrite,assign) id<dataSrcProto> dataSource -(void)start { Port = self.dataSource.serverPort; … start the server } @end ——— dataSource.h/m ———- @class dataSource <dataSrcProto> -(NSUinteger)serverPort{return 8080;} @end ——— dataSrcProto.h ———- @protocol dataSrcProto -(NSUinteger)serverPort; @end Sandor
|
|
Re: Trouble with NSTableViews in macOS 11.x
Sak Wathanasin
I had set the style to "full-width" in IB, but that had no effect. Let me give "plain" a shot. Thanks for the suggestions, Sak
|
|
Re: Trouble with NSTableViews in macOS 11.x
Jon Gotow
I ran into this when updating all of my apps for Big Sur. You'd think the "Full Width" style would make the table, well, full width, but it doesn't. I think the solution was to set the tableview style to "Plain". - Jon
On Fri, Mar 26, 2021 at 1:46 PM Sak Wathanasin <sw@...> wrote:
|
|
Re: Trouble with NSTableViews in macOS 11.x
Shane Stanley
On 27 Mar 2021, at 6:46 am, Sak Wathanasin <sw@network-analysis.ltd.uk> wrote:
Try adding this to your code at an appropriate point: if (@available(macOS 11.0, *)) { myTableView.style = NSTableViewStyleFullWidth; } -- Shane Stanley <sstanley@myriad-com.com.au> <www.macosxautomation.com/applescript/apps/>, <latenightsw.com>
|
|
Trouble with NSTableViews in macOS 11.x
Sak Wathanasin
The tableviews in one of our apps is behaving strangely when running on macOS 11.x. I have managed to reproduce thsi with a simple test app. Essentially, the issue occurs if if I build using the 11.x SDK (ie using Xcode 12.2 or later) when running on 11.x.
What happens is that the table is shifted to the right when running on 11.x. This happens with both view-based and cell-based tables. For example, the frame for the (0,0) cell is on 10.15: (1.0, 1.0, 116.0, 24.0) on 11.2.3: (6.0, 1.0, 116.0, 24.0) Even weirder, if I set the enclosing NSScrollView to "no borders" the frame is now (16.0, 1.0, 116.0, 24.0) AND the grid lines don't extend the full width of the table, AND the line after the last row isn't drawn (that's what got QA on to the case). On 10.15, my test tables look like this - both tables the same except for the border, and both aligned left: But on 11.x, it looks like this: As you can see, the "no border" version is very different. Looking at the release notes (https://developer.apple.com/documentation/macos-release-notes/appkit-release-notes-for-macos-11), the only thing I could see that might be relevant is NSScrollView • When linked on macOS Big Sur 11 or later, an NSScrollViewwith automaticallyAdjustsContentInsets set to truewill continue to respect the safe-area insets of the window even when titlebarAppearsTransparent is set to true. For apps linked earlier than macOS Big Sur 11 NSScrollViewwill ignore the automatic insets when titlebarAppearsTransparent is set to true. But my scrollviews have this turned off. I haven't seen any reports of this issue so I assume I'm doing something very stupid. Any idea what? I can send the test project to anyone who has the time to look at it; it's tiny. Many thanks for any help Sak Wathanasin
|
|
Re: Exception not being caught in try statement
Gary L. Wade
Try surrounding the call with beginEditing and endEditing on the text storage. If it still happens, submit a feedback to Apple with the full crash log.
toggle quoted messageShow quoted text
-- Gary L. Wade http://www.garywade.com/
On Mar 26, 2021, at 4:11 AM, Mark Allan via Cocoa-dev <cocoa-dev@lists.apple.com> wrote:
|
|