UITableViewCellStateMask strange value in Xcode 6.0.1 - xcode

I just upgraded to Xcode 6.0.1. I've got an iOS7 app that has a custom tableViewCell that uses:
- (void)willTransitionToState:(UITableViewCellStateMask)state {
//...code
}
Now, when I place the cell in edit mode in my viewController, the value of "state" is some bizarre new value, "2147483649"
Did something change in the stateMask value, or in how you place a cell in edit mode ?

Got the same problem, only with iOS8 (didn't have this problem on iOS 7.1.1)I noticed that this happens when my tableView is implementing its dataSource delegate method's for reordering cells:
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath;
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath;
When I delete these methods from my tableView's delegate class, I got the correct state from UITableViewCell's [willTransitionToState:] method.
I submitted a bug to apple, bug's number is 18536460, will add a link when available

Related

Button with IBAction causes "Could not connect action, target class NSNibExternalObjectPlaceholder does not respond to -action" error

I have a Storyboard scene which contains an NSTableView with an NSTableViewRow subclass. In this table view row, I have a button which I have wired up to an action in the view controller on the scene.
When the table loads, I am seeing this cryptic error from Xcode and the action never fires when I click the button:
Could not connect action, target class NSNibExternalObjectPlaceholder does not respond to -playVideo:
It looks like the file's owner never gets wired up.
Since these NSTableRowViews get instantiated programmatically, I checked to see if the owner is getting set, and indeed it is:
- (NSView *) tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
...
CombinedHistoryEntryTableCellView *cellView = [tableView makeViewWithIdentifier:#"deviceEvent" owner:self];
...
return cellView;
}
I believe I am experiencing a bug (and I will file a radar later) but I was able to work around the issue by wiring the button up to an action on the CombinedHistoryEntryTableCellView class in IB. Since the code needed to run the action was in the view controller I gave the cell view object a reference to the controller so that it could call it.
Still don't know why that was an issue, though, but if someone else experiences this that is a suitable workaround.

Cannot edit fields in custom UITableViewCell (iOS 9)

after upgrading to iOS 9 (worked fine in iOS 8), I am having trouble clicking UIBUttons and editing UITextFields inside custom UITableViewCells.
I have an UITableView with custom UITableViewCells. These cells are loaded like this:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
...
controller=[[PresetRowViewController alloc] initWithNibName:#"PresetRowViewController" bundle:nil];
...
return (UITableViewCell *)controller.view;
}
The cells show fine, but I cannot click in any UIButton or edit any UITextField inside them.
Any ideas?
Thanks
Try checking for gesture recognizers (ie. view.gestureRecognizers = nil;) for various views (the button, cell itself). Also make sure button.userInteractionEnabled = YES; and cell.userInteractionEnabled = YES; Finally, make sure there's no invisible views overtop of the button/cell.
Try to bring the subviews in the customized table view cell to the front.
I had this same issue. Apple changed how UITableViewCells work in iOS 9. It was fixed for me by dragging in a new UITableViewCell into the Xib and moving everything over. See: https://stackoverflow.com/a/32826526/101923

Hyperlinks in an view-based TableView (NSTableCellView)

I have an view-based TableView with an image and a NSTextField. I've got some links inside my NSTextField and I have tried many options (http://developer.apple.com/library/mac/#qa/qa2006/qa1487.html, dsclickableurltextfield) but nothing works out, because it seems that these options only fit to an cell-based tableview. I also watched the wwdc 2010 cocoa tips and tricks with an good explanation for links inside tableviews. But the custom NSTextFieldCell doesn't work for me. The mouse-events don't reach the custom class and for that reason nothings happens...
I hope you've got the right idea to solve this problem...
You need to add this to your table view's delegate:
- (BOOL)tableView:(NSTableView *)tableView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row
{
return YES; // required for specific tracking control in our NSTextFieldCell
}

Cocoa - View-Based NSTableView, using one cell in multiple tables

I've got a problem. [for which the only example I can find was shown during one of the WWDC 2011 presentations ("Maximising Productivity in Xcode 4"), but there is no source available (it was an app called Birdathon). Everything else I come up with is for iOS, and doesn't translate across.]
Basically, I have some view-based NSTableViews, and currently lay out the image / text fields within my NSTableCellView directly in the column. I've got a subclass of NSTableCellView which gives me the outlets to assign values to each of the text fields I use within that cell. The DataSource and Delegate are implemented and working fine - the TableView with my custom NSTableViewCell works fine.
My problem is I'd like to use the same cell in multiple different tables. Rather than have to recreate the same layout each time, I feel I should be able to draw the NSTableCellView just once in IB. [- and indeed, the Birdathon example I mentioned seemed to show the NSTableCellView being laid out in it's own NIB.]
I've found the answer for iOS in many places, here for example: How do you load custom UITableViewCells from Xib files?
Can anyone help me modify that for Cocoa on Mac?
Thanks,
David
Like this!
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView {
return count;
}
- (NSView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row {
NSView *customView = [tableView makeViewWithIdentifier:#"customview"
owner:self];
…… // set properties
return customView;
}
In interface builder, set the identifier of your custom cell view to "customview" and it will automagically be created! Example:
Just replace "Automatic" with the identifier you are using

cocoa + context sensitive menu on NSTableView with multiple rows selected

i am having a problem displaying context sensitive menu on control click on a tableview when multiple rows are selected.
Its working fine when a single row is selected and then control clicked on it.
The way i am implementing this is shown below:
-(void)doSingleClick
{
NSLog(#"single clicked");
if([[NSApp currentEvent] modifierFlags] & NSControlKeyMask)
{
NSLog(#"control clicked.......");
[NSMenu popUpContextMenu:[self showContextMenu] withEvent:[NSApp currentEvent] forView:tableView];
return;
}
}
and showContextMenu function returns a NSMenu object.
I am dong it this way as my table view for some strange reason does not recognize mouseDown or mouseUp or menuForEvent events.
the problem with the above code segment is, when multiple rows are selected and control clicked, it does not recognize the control click and does not go into that loop and hence not displaying the context menu.
Please suggest me a mechanism to achieve this.
Thanks
I don't recommend the approach that is given in the answers above. Instead, look at the "DragNDropOutlineView" example in Leopard and higher. That, and the release notes, give a proper way to implement contextual menus for a single row, or multiple rows. This includes having AppKit automatically do the proper highlighting.
corbin dunn
(NSTableView Software Engineer)
i hve tableviewcontroller class which is a subclass of NSTableView.
That's very bad naming and suggests that you are not architecting your application properly. Views aren't controllers. Keep them separate.
but this class in which i implemented menuForEvent method but its not getting called for some reason.
Did you make your table view an instance of this class in Interface Builder? If not, your instance is still an NSTableView, and the subclass you wrote is what Ian Hickson might call “a work of fiction”.
Corbin's answer is the best one here.
link text
I don't believe the action method is called when multiple rows are selected.
What would probably be a lot easier would be to override the menuForEvent: method in NSTableView. You'd have to create a subclass of NSTableView to do this, but it would be a cleaner solution.
You could also create an informal protocol (a category on NSObject) and have the NSTableView delegate return the appropriate menu.
#interface NSObject (NSCustomTableViewDelegate)
- (NSMenu *)tableView:(NSTableView *)tableView menuForEvent:(NSEvent *)event;
#end
#implementation NSObject (NSCustomTableViewDelegate)
- (NSMenu *)tableView:(NSTableView *)tableView menuForEvent:(NSEvent *)event {
return nil;
}
#end
And in your NSTableView subclass:
- (NSMenu *)menuForEvent:(NSEvent *)event {
return [[self delegate] tableView:self menuForEvent:event];
}

Resources