UIPopoverController for iPhone by implementing category - ios

I know that Popover controllers are for use exclusively on iPad devices, but on below question there is a comment in which user has mentioned about category, code is as below,
UIPopoverController for iphone not working?
// UIPopoverController+iPhone.h file
#interface UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled;
#end
// UIPopoverController+iPhone.m file
#implementation UIPopoverController (iPhone)
+ (BOOL)_popoversDisabled {
return NO;
}
#end
Is this right way?
Will Apple approve this?,
My iPad application is already done, now I am making it universal application, so instead of using any custom popover I want to add this category so that it will solve my issue and will reduce development efforts.

This is very hacky way, and you'll be taking a big risk putting it on the AppStore. Sure someone may have put a version in the store where they overlooked this, but it can break any moment and Apple may decide to remove his app.
Have you tested popovers on iPhone? Will you test in iOS7.1? Will it work exactly the same on iOS7.2 or iOS 7.3?
A far better solution would be to take an open source implementation of popovers and use that for iPhone (or both).

I have live app with with popover in iPhone.
Just You have to create interface for popover
NSObject+UIPopover_Iphone.h
#import <Foundation/Foundation.h>
#interface UIPopoverController (overrides)
+(BOOL)_popoversDisabled;
#end
NSObject+UIPopover_Iphone.m
#import "NSObject+UIPopover_Iphone.h"
#implementation UIPopoverController (overrides)
+(BOOL)_popoversDisabled
{
return NO;
}
#end
and now just import NSObject+UIPopover_Iphone.h in your Viewcontroller.h
Edit
For iOS 8 you can use
WYPopoverController.

Related

Unidentified box appears at run time

This one has me completely stumped. I'm resurrecting a graphics project that I did a little over a year ago in iOS 6 and XCode 4. It worked just fine then. Now I'm trying to run it in iOS 7 and XCode 6. My UIViewController looks like this in the storyboard, which is how it is supposed to look:
But when I run it, I get this. Notice the strange blue and gray box in the bottom center. I have no idea where this comes from!
I have literally commented out every line of code, so that the implementation file looks like this:
#import "PerspectiveViewController.h"
#implementation PerspectiveViewController
- (void)viewDidLoad
{
[super viewDidLoad];
}
#end
The interface file is like this:
#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>
#interface PerspectiveViewController : GLKViewController
// all of the outlets for the controls, but nothing else
#end
Does anyone have any idea where that blue and gray box is coming from? There used to be a UITabBarController involved, but I stripped that out. Maybe there is still something left over?
The easiest way to debug views which you don't expect to be there is by using a tool like Xcode's UIView inspection or Reveal. You can see many more examples and some discussion in this question: How do I inspect the view hierarchy in iOS?

AR Location based Iphone app error

I am in the process of creating an AR based location iphone app using https://github.com/markrickert/iPhone-AR-Toolkit
I have got these errors and do not know how to fix it. Please will someone help me. With a walkthrough and correct code
Link for image http://i60.tinypic.com/2i9p8c0.png
Seems to be trivial but just check whether you have imported the .h File??
#import "ARKit.h"
"Use of undeclared identifier _arViewController". To fix that simply add a property ARViewController *arViewController; to your #interface.
#interface ScanmarksViewController() {
ARViewController *_arViewController;
}
#end
or
#interface ScanmarksViewController()
#property (strong, nonatomic) ARViewController *arViewController;
#end
Whichever you prefer.

iOS app crashes when set UITextfield delegates

I dont know why the iPhone app crashes and it gives lldb error only.I tried to add the exception break point too.
.h file:
IBOutlet UITextField *etCountry;
.m file:
etCountry.delegate=self;///
This is the line i am getting the crash.Please give me the solution for me
Make sure your textfield has connection like this below images,
This is how
self.etCountry.delegate=self;
And add
#interface YourViewController ()<UITextFieldDelegate>
#end
You may check other threads, and their stack. My guess is that there is everything is fine with text field. Seemingly there seems a network call also in the background, maybe a callback block is not in the right format. That caused similar "hidden" crashes to me.

Adding FGallery to my app

Still new and learning so please please bear with me. I have two issues regarding this topic. A little background. I have developed a app that has 5 tab bar items. One tabBarItems' view (the home view) has 5 buttons. One of these buttons loads the RootViewController for the open source [FGallery Slideshow Project] (https://github.com/gdavis/FGallery-iPhone) created by Grant Davis. I incorporated a good portion of the features into my app. Using a UIButton in HomeViewController I push to the RootViewController which is edited to suite my needs. I made some additions and omissions.
ISSUE 1: MOST IMPORTANT
I have a problem with the app crashing on the Go Back Button (Home if your in the initial load of the RootViewController).After the RootViewController loads I can step through the gallery functions just fine. If I click back (to the previous view) it will crash on Going back to HomeViewController with the following error in the app delegate:
"Thread 1: EXC_BAD_ACCESS(code=11, address=0x10)"
it appears on this line of code:
#import "MyAppleAppDelegate.h"
int main(int argc, char *argv[])
{
#autoreleasepool {
return UIApplicationMain(argc, argv, nil, NSStringFromClass([MyAppleAppDelegate class]));
}
}
ARC is omitted on the classes that make up the Gallery. The rest of the app uses ARC.
Target build is 7.1. Everything works fine if loaded using 6.1 by programmatically targeting Legacy UI but only in the simulator. I have not had a chance to test it on a device running iOS 6.1 only 7.1. Of course with all of apples recent changes It is best to just build for 7.1. Sad thing is when I started this app 6.1 was the standard :(
HomeViewController UIButton to gallery:
-(IBAction)showGallery:(id)sender
{
UIViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:#"gallery"];
[self.navigationController pushViewController:controller animated:YES];
}
ISSUE 2: NOT AS IMPORTANT I AM SURE I CAN FIGURE THIS ONE OUT BUT..
In the view that shows the toolbar which controls which image is showing. The tool bar is hidden under the TabBar along with half of the caption container. In iOS 6; No problem, they stack on top of each other the way they are so-pose to.
Thanks in advance for any help I realize this question might be a bit much.
I fixed my current main issue by converting the FGallery to use ARC.

iOS MKMapView not displaying map in the simulator

I've just started learning iOS development for iPhone, and following a couple of examples regarding how to display a mapView with the MapKit Framework, I found that google map tiles are not displayed, I only get an empty view (grey tiles), at least in the iPhone simulator (I haven't tried on a device).
I also get this error message:
/SourceCache/GoogleMobileMaps_Sim/GoogleMobileMaps-363.1.2/googlenav/mac/Loader.mm:235
server returned error: 403
I found solutions for similar problem when developing for Android, but not for iOS. Could somebody help me with this issue? Adding the MapKit framework to the project is supposed to be enough to get this working, or maybe am I missing some extra settings that are not mentioned in the tutorials I've followed?
Thanks!
This is the simple sample code I used:
// ViewController.h
#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>
#import <CoreLocation/CoreLocation.h>
#interface ViewController : UIViewController
#property (strong, nonatomic) IBOutlet MKMapView *mapView;
#end
// ViewController.m
#import "ViewController.h"
#implementation ViewController
#synthesize mapView=_mapView;
- (void)viewDidUnload {
[super viewDidUnload];
[self setMapView:nil];
}
... more methods...
And in .xib file, I connected a MKMapView to the file's owner mapView outlet. And at this point, according to the tutorial, I am supposed to be able to see a default US map when running the simulator, but I'm always getting the error I posted before at the debug area, and map view displays only the grey empty grid.
I had the same problem - my UIMapView was only showing the grid, but not the actual map. I quit the simulator and then launched the project again - now it showed the map! It seems like iOS simulator does loses the connection sometimes, even though you might be connected on your computer.
Thank you all for your input!
Have you set the delegate to files owner(self)?
Also have you included mapkit framework and the related header files?
For whatever reason, my iOS simulator sometimes just loses connection to the internet (my computer has connection, but the simulator doesn't recognize it). Once I quit and relaunched my simulator, my maps started showing.
The iOS simulator comes with the official maps app included. Open that and verify that it can get tiles, it could be a network issue. Without any code, outlets, delegates or anything the map should show map data.
An empty map view (grey tiles) as you've described I have seen on the iPhone simulator and a device when trying to specify a map region (see code below for example), however the user has not granted access to their location in app settings. Removing this piece of code when running on the simulator resolved the issue.
MKCoordinateRegion mapRegion;
mapRegion.center = self.mapView.userLocation.coordinate;
mapRegion.span.latitudeDelta = 0.02;
mapRegion.span.longitudeDelta = 0.02;
[self.mapView setRegion:mapRegion animated: YES];
In case anyone looking for the solution. Network issue is solely responsible for this issue. Make sure your simulator has network connection and if it is able to load default apple map, you're good to go.
This issue is a little bit tricky because it involves lots of cases, but for me, it was not loading because of the network monitoring application, eg. Charles, make sure that you have an internet connection and it's unmonitored
I solved this problem by connecting to WIFI with my phone. I didn't have a SIM card installed in my phone, so it just showed the tiles. Just make sure you have network connection.

Resources