If tableView.scrollEnabled = NO, then didSelectRowAtIndexPath is not responding to first touch, but only to the second select row. Do you have any idea why??
Please help.
make sure you have not implemented
didDeselectRowAtIndexPath
rather than implementing
didSelectRowAtIndexPath
Related
My problem is simple: I'm waiting to take a screenshot of an MKMapView, and I want to do it only once the map is loaded. Unfortunately, this delegate method is almost always called before the map is actually loaded. I just get a grid, or a few loaded tiles if I'm lucky. Is there a good way to do what I need to do? Or am I missing something in the MKMapViewDelegate protocol?
Thanks!
Perhaps you could try adding a timer and then take the screenshot in the completion block of the timer. Or perhaps, use the mapView:didUpdateUserLocation: delegate method as the callback for the screenshot instead of mapView:DidFinishLoadingMap:
It seems this is one of the many bugs in MapKit in iOS 6. Hopefully it will be fixed with iOS 7.
I have certain code that I am refactoring and this came up
Thanks
Quite easy to tell by yourself, just add one NSLog in each of these methods... But yes, it's called before.
I know that's quite an easy one but I haven't found anything about it.
All I want is how I can get the y-position of a unbutton?
I hope that anyone can help.
Thanks in advance.
Since UIButton is a subclass of UIView you can simply use
button.frame.origin.y
Or you can use a more flexible way
CGRectGetMinY(button.frame)
for example you can get the mid Y pos like this
CGRectGetMidY(button.frame)
I'm sure the answer to this question is embarrassingly basic, but I'm having trouble understanding how the real-time compiling / error-checking in XCode is supposed to work with the dynamic nature of Objective-C.
For example, I want to setEditing:YES for the tableView of whatever the topViewController is in my stack of view controllers. So I try this:
[self.navigationController.topViewController.tableView setEditing: YES animated: YES];
And XCode complains: Property 'tableView' not found on object of type 'UIViewController'.
Now, this code is in a UIViewController, but it would only be called when the topViewController is a UITableViewController, but obviously Xcode doesn't know that.
How do I fix this? Is this indicative of a bad coding practice on my part? I tried wrapping the line in a conditional to test that topViewController.tableView != nil, but Xcode then just bitches about the conditional line :)
EDIT: Thanks to answers by saadnib and Caleb below, this is what I have now:
if ([self.navigationController.topViewController isKindOfClass:([UITableViewController class])] ) {
UITableViewController *topController = (UITableViewController *)self.navigationController.topViewController;
[topController.tableView setEditing: YES animated: YES];
}
Actually you can access the property of topViewController by typecasting it. For example your topViewController name is "FirstViewController" then you can do this as
FirstViewController *fvc = (FirstViewController*)self.navigationController.topViewController;
[fvc.tableView setEditing: YES animated: YES];
i hope this will help you.
You get the error because self.navigationController.topViewController returns a pointer of type UIViewController*, and UIViewController doesn't have a tableView property. #saadnib's answer is correct: if you know that the pointer will always point to a certain UIViewController subclass, you can cast it to that type.
However, even though you "know" that the top view controller will always be a table view controller, you might want to check at run time that that's the case. You could use -isKindOfClass: to see if the controller is a subclass of UITableViewController. You'd still need the cast, of course, but it'd be a little safer.
I am looking for a way to force any window (even the ones where I am not the owner) to redraw. It has to work for all window (cocoa, carbon , ...)
Do you have any pointer to achieve this?
Thanks in advance for your help,
Regards,
You must set this property in the initWithWindow method [self setShouldCascadeWindows:NO];
,here the self refers to the window that is being initiated.