didSelectAnnotationView not called for ipad - iphone

I am working on universal ios app which runs on iPhone, iPad and iPod-touch. I have
implemented the code for annotation and on selecting this annotation a callout would be
raised. It works fine for iPhone but didSelectAnnotationView method not called for iPad.
Should i add any additional to work for iPad? Thanks in advance

In your code i think you just forget to set Delegate in checking of device if else condition. please check Properly. if didSelectAnnotationView called in iphone but not in ipad it means for ipad condition you not set mapView.delegate = self; for ipad Condition.
So please check properly and set its delegate if your code working for iPhone so that probability for your issue.

see if adding this helps. [annotationView setCanShowCallout:NO]

Related

iPhone 5.0 and 5.1 Simulators Not Calling IBActions?

I have an app with a target of iOS 5.0. Unfortunately, I no longer have any test devices with iOS 5.
I'd like to be able to use the iOS 5.0 and 5.1 simulators to do basic debugging, but for some reason, my IBActions aren't being called on these simulators.
Further info:
Xcode version is 4.5.2
All simulators are up-to-date (no pending updates/downloads available)
We do have customers who use iOS 5 and 5.1, and they don't have any issues clicking the buttons (or at least, we haven't received any reports about such from them ; )
On the iPhone 6.0 simulator, everything works as expected (pretty sure all IBActions are connected correctly)
Are these simulators just terribly buggy (is this a known issue)? Have others ran into this issue and know a fix?
It turns out that a UITapGesture on self.view was capturing the touches and NOT forwarding to the subviews... for some reason, this behavior appears to be different in iOS 6 and iOS 5 simulators... user beware...
Most Probably issue i seen that..
might be you not define your IBAction method in .h file.
might be you connect two IBAction on one UIButton TouchUpInside.
you also try uninstall app from simulatore clear xcode than might be solve your issue.
reset you simulator contain.
Check is any update of Xcode then you try to run your app then you got solution.
I am working on same configuration and i have no issue like yours..
Use UIGestureRecognizerDelegate to avoid effect of gestureRecognizer on a selectedView:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)recognizer shouldReceiveTouch:(UITouch *)touch {
UIView *selectedView = self.view;
CGPoint point = [touch locationInView:self.view.superview];
if (CGRectContainsPoint(selectedView.frame, point)) {
return NO;
}
else {
return YES;
}
}

How to enable "AutoLayout" of iOS 6 programmatically?

How can I enable "AutoLayout" programmatically. Actually I have to create an app which should run on iOS6 and iOS5 but we can enable "AutoLayout" in the XIB in iOS 6 only and it will not work on the iOS 5 so I am checking the iOS version and using if else condition for the appropriate task according to the iOS. So if app would be running on iOS 6, I will enable the AutoLayout otherwise I will write the code for AutoResizing. Please let me know if I am unclear at any point.
If you want autolayout on iOS6 devices but not iOS5 (unuspported) but still want to use nib's, you have to keep separate nibs. One for iOS5 and one for iOS6.
When loading your nib, check if autolayout is supported by checking if the NSLayoutConstraint class exists:
if (NSClassFromString(#"NSLayoutConstraint"))
//Load iOS6 nib with autlayout.
else
//Load iOS5 nib sans autolayout.

2 XIB and 1 viewcontroller but functions don't work in the ipad XIB

I believe that I did everything necessary to change my app for ipad (was for iphone at start). I can toggle the build status to either iphone (only), ipad (only) or iphone/ipad - and the app launches either in ipad or iphone simulator. I can do that forth and back at will.
I added the idiom to check for ipad and basically for one of my xib, instead of using the string of my xib to create the controller, I use the one for the ipad. So it is a new xib for ipad with all same graphical objects ( enlarged ;-) ) . I added the callbacks to function correctly with IB.
I can see everything fine and arrive on my new ipad view BUT when I click on one of my buttons... nothing happened like if my callbacks don't work. It is very surprising and actually I have no idea where to look as I compared most of the parameters between my iphone and ipad view and they are identical as far as I can see.
It must be something damn obvious so if one of you had the same issue and it was a very simple answer ... I guess that would be what I missed!
Thanks for your help in advance
Cheers,
geebee
EDIT1: Some code as requested
at start I have that to decide either way:
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
examTFVC_NIB=#"ExamTFViewController-iPad";
}
else
{
examTFVC_NIB=#"ExamTFViewController";
}
Then to go to the right view:
ExamTFViewController *examTFViewController = [[ExamTFViewController alloc]
initWithNibName:globals.examTFVC_NIB bundle:nil];
But I have no problem loading the correct XIB. The issue is really the callback functions not being called...
Thanks for the help.
EDIT2:
I also realised that calling the extension of the xib xxx~ipad allows to avoid the example code above. And it works - but still no function can be called.
EDIT3:
IMPORTANT FINDING: if I move my buttons higher and on the left of the screen: they work! So it seems that the functions are called if the event are in the region of an iphone screen although I am on an ipad screen. I guess know it would be more obvious to find the issue! thanks for any help – geebee just now
ANSWER
iPad touch detected only in 320x480 region
- (void)applicationDidFinishLaunching:(UIApplication *)application {
// to correct region size
CGRect rect = [[UIScreen mainScreen] bounds];
[window setFrame:rect];
// now, display your app
[window addSubview:rootController.view];
[window makeKeyAndVisible];
}
** OR OTHER SOLUTION **
Check the full screen at launch checkbox - only present in the ipad xib MainWindow
finally solved - with 2 methods - programmatically or via IB - in the edited section of the post.

Will iAds be loaded, if I hide the ADBannerView?

I know Apple recommends just placing the adview offscreen,
incase there is an error, loading an iAd,
but I would like to hide it using [adView setHidden: YES];.
If I do so, will the view check for new ads available?
In the simulator sure it will load the Test Ads,
but will it also work after releasing the app onto actual devices from the AppStore?
SideSwipe
Yes, it should work on real device.

always returns nil in iPhone

I am trying to apply Mike Chen's answer here, using SDK 3.0. In delegate.m file I implement;
[viewController.view addSubview:[[objc_getClass("PLCameraController") sharedInstance] previewView]];
and in viewcontroller.m I implement:
PLCameraController *cam = [objc_getClass("PLCameraController") sharedInstance];
CapturedImage = [cam _createPreviewImage];
but 'cam' is always nil. Any suggestions?
This won't work when running in the simulator or on an iPod Touch. Are you running this on a physical iPhone with a camera?
Also, if you've dumped the headers correctly, you shouldn't be using the objc_ runtime functions, but rather using the class names. Is the result of objc_getClass("PLCameraController") set to nil?
On a side note: I hope you're not looking to publish your application through the App Store because this sort of private method calling is a great excuse for Apple to reject your application.
To use PLCameraController, you'll need to include the PhotoLibray private framework. The simplest way to do that is drag drop an Image Picker Controller (UIImagePickerController) into your main nib.