Scroll View Resizing Problem
Hi, I have a scroll view with a fixed height but variable length. I'm adding Image Views to it and each image has a height of 200 but a variable length. I have the scroll view height set to 200 and the width set to the width of an iPad screen - 1024. When I run this on an iPad 2 or the simulator using iOS 6, everything works, but the images in the Scroll View have the bottom chopped of and you can scroll vertically. As an experiment, I changed the height in IB to be 240 and this stops it from scrolling! Under iOS 7, in the simulator, the scroll view behaves as expected, e.g. it scroll horizontally, but not vertically. Any ideas on what could be causing this would be appreciated. This is a Landscape only App. All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Predicate syntax and localisation
On Oct 6, 2013, at 3:45 PM, Laurent Cerveau wrote: I am using NSPredicateEditor to display some predicates and after a few fights all is now fine. A feature I find particularly convenient is the use of a formatting dictionary to display user friendly sentences to a user. In another part of my application, I show some data computed based on the edited predicate and I would like to show the predicate that originates this result but in a human friendly way. So I thought I would reuse this dictionary/strings file. So basically I would like to have code like NSLocalizedString(predicate.predicateFormat, nil); However predicateFormat does not seem to return proper localizable predicate. That is for example loc name BEGINSWITH MM and not loc name begins with MM Or volumeType == 27 while I have volumeType is 27 in the strings file. Is there a way to convert between the 2 (or do I miss a point?) It is not the canonical way to use localization, but you theoretically should be able to use it in this way, as long as all of your predicate strings are static and have an exact character for character match in your Localizable.strings or equivalent file. IMHO it would be better to simply have a translation routine that converts predicates to a desired plain-language that itself could be properly localized to produce, for instance, volumeType est de 27 as well. HTH, Keary Suska Esoteritech, Inc. Demystifying technology for your home or business ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Infinite Scroll View?
Hi, I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling is past the last item in the Scroll start displaying the first and when scrolling before the first item, starting displaying the last. The items in this case are UIImageViews and they have a fixed height and a variable width and no one image will be wider that the Scroll View itself. Also it needs to work with pagingEnables = NO, e.g. there will be more than one Image visible. I've playing around a bit and found a some sample code that sort of does it but it doesn't handle the wrapping the Images smoothly (is was written to have paging enabled). My plan was/is to detect when the scrolling had hit before the first/after the last and to move the first Subview to the End or the Last one to the beginning, depending on the direction of movement, but at the moment, I can't seem to see a way of detecting these conditions. I logged contentOffset and contentSize in the scrollViewDidScroll delegate method and got these results: scrollViewDidScroll Offset: {4017, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4061, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4095, 0} - Size: {5119, 200} When hitting the end and scrollViewDidScroll Top Scroll View Offset: {106, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {24, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {-0, 0} - Size: {5119, 200} When hitting the start. I'm not sure how if I can detect the start/end conditions using these values? Any points on the best way to implement this would greatly appreciated! All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Infinite Scroll View?
There’s a WWDC video from 2011 : “Advanced ScrollView Techniques” which explains one way to do infinite scrolling. Look at 18:08 if it is what you want. On 07/10/2013, at 13:21, Dave d...@looktowindward.com wrote: Hi, I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling is past the last item in the Scroll start displaying the first and when scrolling before the first item, starting displaying the last. The items in this case are UIImageViews and they have a fixed height and a variable width and no one image will be wider that the Scroll View itself. Also it needs to work with pagingEnables = NO, e.g. there will be more than one Image visible. I've playing around a bit and found a some sample code that sort of does it but it doesn't handle the wrapping the Images smoothly (is was written to have paging enabled). My plan was/is to detect when the scrolling had hit before the first/after the last and to move the first Subview to the End or the Last one to the beginning, depending on the direction of movement, but at the moment, I can't seem to see a way of detecting these conditions. I logged contentOffset and contentSize in the scrollViewDidScroll delegate method and got these results: scrollViewDidScroll Offset: {4017, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4061, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4095, 0} - Size: {5119, 200} When hitting the end and scrollViewDidScroll Top Scroll View Offset: {106, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {24, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {-0, 0} - Size: {5119, 200} When hitting the start. I'm not sure how if I can detect the start/end conditions using these values? Any points on the best way to implement this would greatly appreciated! All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/marcelo.alves%40me.com This email sent to marcelo.al...@me.com ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Infinite Scroll View?
Have you thought about representing your images as cells in a UITableView? If so, you could use something like BBTableView (https://github.com/bharath2020/UITableViewTricks). It's a subclass of UITableView lays out cells along an arc but it also has support for infinite scrolling, so you could just use the relevant pieces. Plus UITableView will handle putting the right image in the right vertical location, based on your data source. On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote: Hi, I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling is past the last item in the Scroll start displaying the first and when scrolling before the first item, starting displaying the last. The items in this case are UIImageViews and they have a fixed height and a variable width and no one image will be wider that the Scroll View itself. Also it needs to work with pagingEnables = NO, e.g. there will be more than one Image visible. I've playing around a bit and found a some sample code that sort of does it but it doesn't handle the wrapping the Images smoothly (is was written to have paging enabled). My plan was/is to detect when the scrolling had hit before the first/after the last and to move the first Subview to the End or the Last one to the beginning, depending on the direction of movement, but at the moment, I can't seem to see a way of detecting these conditions. I logged contentOffset and contentSize in the scrollViewDidScroll delegate method and got these results: scrollViewDidScroll Offset: {4017, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4061, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4095, 0} - Size: {5119, 200} When hitting the end and scrollViewDidScroll Top Scroll View Offset: {106, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {24, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {-0, 0} - Size: {5119, 200} When hitting the start. I'm not sure how if I can detect the start/end conditions using these values? Any points on the best way to implement this would greatly appreciated! All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Infinite Scroll View?
Hi, I don't think that will work for me in this case as I need the images to be scrolled smoothly without gaps and AFAIK, using a table view cell will cause a gap - you can add a fragment of an image. Thanks anyway All the Best Dave On 7 Oct 2013, at 18:11, Steve Christensen puns...@mac.com wrote: Have you thought about representing your images as cells in a UITableView? If so, you could use something like BBTableView (https://github.com/bharath2020/UITableViewTricks). It's a subclass of UITableView lays out cells along an arc but it also has support for infinite scrolling, so you could just use the relevant pieces. Plus UITableView will handle putting the right image in the right vertical location, based on your data source. On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote: Hi, I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling is past the last item in the Scroll start displaying the first and when scrolling before the first item, starting displaying the last. The items in this case are UIImageViews and they have a fixed height and a variable width and no one image will be wider that the Scroll View itself. Also it needs to work with pagingEnables = NO, e.g. there will be more than one Image visible. I've playing around a bit and found a some sample code that sort of does it but it doesn't handle the wrapping the Images smoothly (is was written to have paging enabled). My plan was/is to detect when the scrolling had hit before the first/after the last and to move the first Subview to the End or the Last one to the beginning, depending on the direction of movement, but at the moment, I can't seem to see a way of detecting these conditions. I logged contentOffset and contentSize in the scrollViewDidScroll delegate method and got these results: scrollViewDidScroll Offset: {4017, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4061, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4095, 0} - Size: {5119, 200} When hitting the end and scrollViewDidScroll Top Scroll View Offset: {106, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {24, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {-0, 0} - Size: {5119, 200} When hitting the start. I'm not sure how if I can detect the start/end conditions using these values? Any points on the best way to implement this would greatly appreciated! All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Infinite Scroll View?
Does it not work to set the row height to the height of each of the images and then use a custom UITableViewCell that contains a UIImageView that fills the cell? The other benefit is that you don't have to have more images in memory than are visible within the table view's frame. (This may not be an issue if there aren't that many, of course.) On Oct 7, 2013, at 10:25 AM, Dave d...@looktowindward.com wrote: Hi, I don't think that will work for me in this case as I need the images to be scrolled smoothly without gaps and AFAIK, using a table view cell will cause a gap - you can add a fragment of an image. Thanks anyway All the Best Dave On 7 Oct 2013, at 18:11, Steve Christensen puns...@mac.com wrote: Have you thought about representing your images as cells in a UITableView? If so, you could use something like BBTableView (https://github.com/bharath2020/UITableViewTricks). It's a subclass of UITableView lays out cells along an arc but it also has support for infinite scrolling, so you could just use the relevant pieces. Plus UITableView will handle putting the right image in the right vertical location, based on your data source. On Oct 7, 2013, at 9:21 AM, Dave d...@looktowindward.com wrote: Hi, I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling is past the last item in the Scroll start displaying the first and when scrolling before the first item, starting displaying the last. The items in this case are UIImageViews and they have a fixed height and a variable width and no one image will be wider that the Scroll View itself. Also it needs to work with pagingEnables = NO, e.g. there will be more than one Image visible. I've playing around a bit and found a some sample code that sort of does it but it doesn't handle the wrapping the Images smoothly (is was written to have paging enabled). My plan was/is to detect when the scrolling had hit before the first/after the last and to move the first Subview to the End or the Last one to the beginning, depending on the direction of movement, but at the moment, I can't seem to see a way of detecting these conditions. I logged contentOffset and contentSize in the scrollViewDidScroll delegate method and got these results: scrollViewDidScroll Offset: {4017, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4061, 0} - Size: {5119, 200} scrollViewDidScroll Offset: {4095, 0} - Size: {5119, 200} When hitting the end and scrollViewDidScroll Top Scroll View Offset: {106, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {24, 0} - Size: {5119, 200} scrollViewDidScroll Top Scroll View Offset: {-0, 0} - Size: {5119, 200} When hitting the start. I'm not sure how if I can detect the start/end conditions using these values? Any points on the best way to implement this would greatly appreciated! All the Best Dave ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
ARC and NSError output parameters: proper declaration?
Hi all, I understand the issue with NSError output parameters and ARC, and that it automatically 'adds' an __autoreleasing, but I'm wondering what is the recommended way to declare NSError output parameters in new code these days: 1) No decorations, ex: - (BOOL)foobar:(NSError **)outError; 2) 'out' tag, ex NSKeyValueCoding.h - (BOOL)validateValue:(inout id *)ioValue forKey:(NSString *)inKey error:(out NSError **)outError; 3) explicit __autoreleasing - (BOOL)foobar:(NSError * __autoreleasing *)outError; Which is preferable? I'm interested both in term of correctness and style/coding standards. Thanks, -- Sean McBride, B. Eng s...@rogue-research.com Rogue Researchwww.rogue-research.com Mac Software Developer Montréal, Québec, Canada ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Infinite Scroll View?
On Mon, Oct 7, 2013, at 11:04 AM, Steve Christensen wrote: Does it not work to set the row height to the height of each of the images and then use a custom UITableViewCell that contains a UIImageView that fills the cell? The other benefit is that you don't have to have more images in memory than are visible within the table view's frame. (This may not be an issue if there aren't that many, of course.) Dave is scrolling horizontally, not vertically. UITableView is of no help here. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Infinite Scroll View?
On Mon, Oct 7, 2013, at 09:21 AM, Dave wrote: Hi, I'd like to be able to Scroll Infinitely in a Scroll, e.g. when the scrolling is past the last item in the Scroll start displaying the first and when scrolling before the first item, starting displaying the last. The items in this case are UIImageViews and they have a fixed height and a variable width and no one image will be wider that the Scroll View itself. Also it needs to work with pagingEnables = NO, e.g. there will be more than one Image visible. I've playing around a bit and found a some sample code that sort of does it but it doesn't handle the wrapping the Images smoothly (is was written to have paging enabled). My plan was/is to detect when the scrolling had hit before the first/after the last and to move the first Subview to the End or the Last one to the beginning, depending on the direction of movement, but at the moment, I can't seem to see a way of detecting these conditions. It seems fairly straightforward, if a little labor intensive, to figure out the width and placement of all your image views, override -layoutSubviews to position only the ones that are potentially visible, and implement -scrollViewWillEndDragging:withVelocity:targetContentOffset: to figure out where to end scrolling, based on the current velocity. --Kyle Sluder ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: ARC and NSError output parameters: proper declaration?
On Oct 7, 2013, at 1:44 PM, Sean McBride s...@rogue-research.com wrote: Hi all, I understand the issue with NSError output parameters and ARC, and that it automatically 'adds' an __autoreleasing, but I'm wondering what is the recommended way to declare NSError output parameters in new code these days: 1) No decorations, ex: - (BOOL)foobar:(NSError **)outError; 2) 'out' tag, ex NSKeyValueCoding.h - (BOOL)validateValue:(inout id *)ioValue forKey:(NSString *)inKey error:(out NSError **)outError; 3) explicit __autoreleasing - (BOOL)foobar:(NSError * __autoreleasing *)outError; Which is preferable? I'm interested both in term of correctness and style/coding standards. If you know the clients of your code are always going to be using ARC, you could use (NSError * __strong *). This would slightly reduce the number of autoreleased objects you generate, as well as prevent crashes caused by things like this: - (BOOL)foo:(NSError * __autoreleasing *)error { @autoreleasepool { return [someObject bar:error]; } } Charles ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Question about menuHasKeyEquivalent:forEvent:target:action:
Why is it that if I use the menu delegate method menuHasKeyEquivalent:forEvent:target:action: to search for a key equiv in one of our submenus, the action method gets called with the menu as the sender instead of the menu item? I see now way to say use this menu item as the sender when you send the action to the target. To work around this, I am simply returning NO from menuHasKeyEquivalent and calling performActionForItemAtIndex: from it. Is that a valid workaround? -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about menuHasKeyEquivalent:forEvent:target:action:
On Oct 7, 2013, at 2:33 PM, Steve Mills wrote: Why is it that if I use the menu delegate method menuHasKeyEquivalent:forEvent:target:action: to search for a key equiv in one of our submenus, the action method gets called with the menu as the sender instead of the menu item? I see now way to say use this menu item as the sender when you send the action to the target. To work around this, I am simply returning NO from menuHasKeyEquivalent and calling performActionForItemAtIndex: from it. Is that a valid workaround? What exactly are you trying to do? Are you perhaps just looking for -[NSMenu performKeyEquivalent:]? The behavior of your -menuHasKeyEquivalent:... method is up to you. Are you asking why your method does what it does? We can't know. In any case, calling that should not invoke the action on any target. So: a) I don't understand your first paragraph, and b) the answer to your question in the second paragraph is NO. The -menuHasKeyEquivalent:… delegate method is mostly not very useful. As discussed in the WWDC 2010 Session 145 - Key Event Handling in Cocoa Applications video (around 6:55), the main use of that method is to return NO for menus that you know do _not_ have key equivalents, to optimize the search. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about menuHasKeyEquivalent:forEvent:target:action:
On Oct 7, 2013, at 14:50:31, Ken Thomases k...@codeweavers.com wrote: On Oct 7, 2013, at 2:33 PM, Steve Mills wrote: Why is it that if I use the menu delegate method menuHasKeyEquivalent:forEvent:target:action: to search for a key equiv in one of our submenus, the action method gets called with the menu as the sender instead of the menu item? I see now way to say use this menu item as the sender when you send the action to the target. To work around this, I am simply returning NO from menuHasKeyEquivalent and calling performActionForItemAtIndex: from it. Is that a valid workaround? What exactly are you trying to do? Are you perhaps just looking for -[NSMenu performKeyEquivalent:]? I'm trying to work around an Apple bug described in my previous question to this list, performKeyEquivalent is finding the wrong menu item when item 1 uses unmodified-1 and item 2 uses control-1. The behavior of your -menuHasKeyEquivalent:... method is up to you. Are you asking why your method does what it does? We can't know. In any case, calling that should not invoke the action on any target. So: a) I don't understand your first paragraph, and b) the answer to your question in the second paragraph is NO. If menuHasKeyEquivalent returns YES, then the method that gets called to handle the menu item (the action) is given the menu as the sender (the same menu that was asked menuHasKeyEquivalent, not even the submenu that directly owns the menu item that was found). Normally, the menu *item* is sent as the sender to the action. -(IBAction) doSomething:(id)sender Here, sender should be an NSMenuItem, not an NSMenu. To work around *that* problem, I'm calling performActionForItemAtIndex directly in my menuHasKeyEquivalent. The menu title in the menubar correctly flashes, so it doesn't *seem* like it's a bad thing to do. The -menuHasKeyEquivalent:… delegate method is mostly not very useful. As discussed in the WWDC 2010 Session 145 - Key Event Handling in Cocoa Applications video (around 6:55), the main use of that method is to return NO for menus that you know do _not_ have key equivalents, to optimize the search. I didn't realize I had to also watch videos in order to find documentation. The actual documentation doesn't say what it's main reason is, simply that you can return YES if an item handles it and supply and target and action, or NO if no items handles it. This seems like a pretty good way to work around the Apple bug. If Apple knows something different, it should be in readable/searchable documentation, not a video. -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about menuHasKeyEquivalent:forEvent:target:action:
On Oct 7, 2013, at 3:09 PM, Steve Mills wrote: On Oct 7, 2013, at 14:50:31, Ken Thomases k...@codeweavers.com wrote: On Oct 7, 2013, at 2:33 PM, Steve Mills wrote: To work around this, I am simply returning NO from menuHasKeyEquivalent and calling performActionForItemAtIndex: from it. Is that a valid workaround? the answer to your question […] is NO. Here, sender should be an NSMenuItem, not an NSMenu. To work around *that* problem, I'm calling performActionForItemAtIndex directly in my menuHasKeyEquivalent. The menu title in the menubar correctly flashes, so it doesn't *seem* like it's a bad thing to do. The problem is that you can't be sure that -menuHasKeyEquivalent:… is only called when a matching menu item's action would be performed. The frameworks might have other reasons for invoking that method. Also, if you answer NO, then presumably NSMenu keeps searching and may find another match (perhaps not even among your menu items; perhaps for a Service or whatever). Then, both actions would fire. The -menuHasKeyEquivalent:… delegate method is mostly not very useful. As discussed in the WWDC 2010 Session 145 - Key Event Handling in Cocoa Applications video (around 6:55), the main use of that method is to return NO for menus that you know do _not_ have key equivalents, to optimize the search. I didn't realize I had to also watch videos in order to find documentation. The actual documentation doesn't say what it's main reason is, simply that you can return YES if an item handles it and supply and target and action, or NO if no items handles it. This seems like a pretty good way to work around the Apple bug. If Apple knows something different, it should be in readable/searchable documentation, not a video. Well, sure, I agree that the written documentation should be complete. It often isn't, though, and one needs to consult headers, WWDC videos, or even the lore of your fellow developers. But, having been directed to another source of information, it doesn't seem wise to simply ignore it out of irritation. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Autolayout fixed size centering in VFL
Bringing this back up again ... Also, I suspect the reason you're specifying center-X alignment when creating the vertical constraints is because NSLayoutConstraint threw an exception when you tried to use the center-Y alignment option. That should be warning enough. ;-) Ignoring the larger problem for a minute, I don't think this specific alignment option is actually surprising. If you create a VERTICAL vfl string, the options value attribute tells the elements in the string how to line up. The string itself defines how the views relate to each other vertically - so it makes sense that the option value defines how the elements line up on the X axis. Specifically, with a string like this: @V:|-[titleLabel]-[descLabel]-[warningButton]-|; as part of [NSLayoutConstraint constraintsWithVisualFormat:VFLString options:NSLayoutFormatAlignAllLeft metrics:metrics views:views] the *NSLayoutFormatAlignAllLeft* option will line up each of the elements in the string (titleLabel, descLabel, warningButton) by their left edge. Given that 'warningButton' is the widest of the elements, If I add another constraint: @H:|-[warningButton]-| The constraints work together to both center the warningButton across the screen and then line up all the other elements according to the X axis option applied to the V: constraint. *Therefore, I now think that the original constraint we were talking about is correctly using the x-alignment when specifying a Vertical alignment.* So now, back to the original suggested code using VFL to center a view within its parent; I came across this post on objc.iohttp://www.objc.io/issue-3/advanced-auto-layout-toolbox.htmltoday which has the exact same code suggestion - and then proceeds to give a reasonable explanation as to why it works. If you visit the page, scroll down about 7/8 of the way through the article and you'll find it. This uses the option NSLayoutFormatAlignAllCenterX to create the actual centering constraint between the super view and the subview. The format string itself is merely a dummy that results in a constraint specifying that there should be less than one point of space between the super view’s bottom and the subview’s top edge, which is always the case as long as the subview is visible. You can reverse the dimensions in the example to achieve centering in the vertical direction. I'm still not sure how to rectify your superview / childview concern ... is there a formal condition on a VFL string that it cannot include elements at different levels in the view hierarchy - or more specifically, is it syntactically incorrect to include a parent and child view in that string? Curious if this behavior on iOS is expected then, or a bug. Thanks, -Luther On Fri, Oct 4, 2013 at 11:29 PM, Luther Baker lutherba...@gmail.com wrote: Also, I suspect the reason you're specifying center-X alignment when creating the vertical constraints is because NSLayoutConstraint threw an exception when you tried to use the center-Y alignment option. That should be warning enough. ;-) This is true - as I typed this block into my own project I naturally lined up the V: vfl string with the Y constant and the H: vfl string with the X constant ... and it complained. I then noticed that evgenyneuhttps://github.com/evgenyneu/center-vfl had flipped them. Thanks - it now feels like this is an anomaly at best. -Luther On Fri, Oct 4, 2013 at 11:03 PM, Kyle Sluder k...@ksluder.com wrote: On Fri, Oct 4, 2013, at 08:22 PM, Luther Baker wrote: First of all ... very much appreciate you both so often! Thanks for commenting as much as you do. I too faced this issue and, like Kyle, read enough to assume it was generally not possible with VFL. But this afternoon, I came across this: https://github.com/evgenyneu/center-vfl and for my specific case, it works perfectly. Let me know what you think ... and if you see caveats. I'm successfully using this technique to center an ImageView populated with an image much larger than the iPhone's screen on a simple, standard plain old ViewController's view. This doesn't work on OS X, and I'm surprised it works on iOS. UIView *superview = self.view; NSDictionary *variables = NSDictionaryOfVariableBindings(label, superview); NSArray *constraints = [NSLayoutConstraint constraintsWithVisualFormat:@V:[superview]-(=1)-[label] options: NSLayoutFormatAlignAllCenterX metrics:nil views:variables]; [self.view addConstraints:constraints]; This specifies a relationship between the superview's bottom edge and the label's top edge, yet the label is a subview of the superview. When running on the Mac, I would expect
Re: Question about menuHasKeyEquivalent:forEvent:target:action:
On Oct 7, 2013, at 15:19:31, Ken Thomases k...@codeweavers.com wrote: The problem is that you can't be sure that -menuHasKeyEquivalent:… is only called when a matching menu item's action would be performed. The frameworks might have other reasons for invoking that method. Ack, that's a good point. Cripes. Also, if you answer NO, then presumably NSMenu keeps searching and may find another match (perhaps not even among your menu items; perhaps for a Service or whatever). Then, both actions would fire. I mistakenly typed NO in my original message. It should've said: To work around this, I am simply returning YES from menuHasKeyEquivalent and calling performActionForItemAtIndex: from it. Is that a valid workaround? -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about menuHasKeyEquivalent:forEvent:target:action:
On Oct 7, 2013, at 4:04 PM, Steve Mills wrote: On Oct 7, 2013, at 15:19:31, Ken Thomases k...@codeweavers.com wrote: Also, if you answer NO, then presumably NSMenu keeps searching and may find another match (perhaps not even among your menu items; perhaps for a Service or whatever). Then, both actions would fire. I mistakenly typed NO in my original message. It should've said: To work around this, I am simply returning YES from menuHasKeyEquivalent and calling performActionForItemAtIndex: from it. Is that a valid workaround? I guess it's moot in light of my other point but: then NSMenu is sure to invoke the returned action on the returned target (in the case where it was really intending to perform the key equivalent), wouldn't it? Or are you setting the target and action to values that will do nothing? Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Re: Question about menuHasKeyEquivalent:forEvent:target:action:
On Oct 7, 2013, at 16:14:33, Ken Thomases k...@codeweavers.com wrote: I guess it's moot in light of my other point but: then NSMenu is sure to invoke the returned action on the returned target (in the case where it was really intending to perform the key equivalent), wouldn't it? Or are you setting the target and action to values that will do nothing? I was returning nil for the target and action so it will not try to invoke them. Since I can't rely on menuHasKeyEquivalent, I tried subclassing NSMenu so I could override performKeyEquivalent, but that method isn't even called on my subclass. Hrmph. -- Steve Mills office: 952-818-3871 home: 952-401-6255 cell: 612-803-6157 ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com