getting default user interface from GKPeerPickerController class - iphone

i am developing an application which needs bluetooth conection of two iPhones.Now this is what i did:
I created a view based application
I included GameKit Framework in my application.
I did not do anything to my app delegate file and in my view controller's view did load method i wrote folowing piece of code
[super viewDidLoad];
mPicker=[[GKPeerPickerController alloc] init];
mPicker.delegate=self;
mPicker.connectionTypesMask = GKPeerPickerConnectionTypeNearby;
mPeers=[[NSMutableArray alloc] init];
mPicker.show;
now i expected the default interface to be shown when my application is launched because this is what is written in my didFinishLaunchingWithOption method of applicationdelegate
[window addSubview:viewController.view];
[window makeKeyAndVisible];
return YES;
what else i need to do to make the defaultinterface visible.I have implemented delegate methods of GKPeerPickerController.
Thanks in advance....

You can check this tutorial.This is for chat application but this shows how to display picker
ui.rest part that is related to that you can exclude it.
http://www.devx.com/wireless/Article/43502/1954

You have a simple bug. This line:
mPicker.show;
should be:
[mPicker show];

Related

App wont start using testflight on iOS6

I have an application that I want to test it on iOS device. The application uses NIB files and no story board.
Target framework is set to - 5.1
Device - Universal.
I have created the IPA file and uploaded to TestFlightApp.
I have downloaded and installed the application on my iPad. Weird thing is when I tap on the icon a black screen shows and nothing else happens.
I have done the following settings.
Main Interface - SSDMainViewController
Main Storyboard - Not set as I don't have any storyboard in the applicaion.
It is not the problem of IOS versions as other apps are working fine.
EDIT : When I double click the iPad button I saw that the application
is not crashing. It is running in the background.
EDIT 2 : More information on the question.
Well I have taken a view based application and it has all NIBs no storyboard. It was initially an iPhone application targeting the IOS 5.1 but then I have changed the value from the project drop down to UNIVERSAL. But that I think is no problem because when I installed it in my iPad it showed me nothing. Also it showed black screen with the iPhone frame and then nothing. The application is still live in the thread.
What bothers me is that I have done this in the AppDelegate :
I have set the
self.mainViewController = [[SSDMainViewController alloc] initwithnibname:#"SSDMainViewController" bundle:nil];
And then I have set the navigation controller and then pushed the view to it.
I FOUND SOME MORE INFORMATION
In the console it says.
The application is expected to have its root view set at the end of application start.
MY APP DELEGATE
ftipValue=0.25;
cardtype = #"American Express";
[cardtype retain];
[self CallFunctionForLogout];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Create an instance of YourViewController
//SSDMainViewController *yourViewController = [[SSDMainViewController alloc] init];
self.mainViewController = [[[SSDMainViewController alloc] initWithNibName:#"SSDMainViewController" bundle:nil] autorelease];
// Create an instance of a UINavigationController
// its stack contains only yourViewController
UINavigationController *navController = [[UINavigationController alloc]
initWithRootViewController:self.mainViewController];
navController.navigationBarHidden = YES;
// Place navigation controller's view in the window hierarchy
[[self window] setRootViewController:navController];
[self.window makeKeyAndVisible];
return YES;
Please use two xib file, universal app we want two xib (nib)
one for iPhone - ViewController_iPhone
second for for iPad - ViewController_iPad
Add following code to your AppDelegate.m file.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
{
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPhone" bundle:nil] autorelease];
}
else {
self.viewController = [[[ViewController alloc] initWithNibName:#"ViewController_iPad" bundle:nil] autorelease];
}
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
I have done this and it's work fine for me.
That error means that you're not setting up your application correctly.
You say you've set SSDMainController as the main interface file - is this both for iPhone and iPad? There are two sets of entries in that section of the summary tab for universal apps.
I would expect a different xib file to be specified for the iPad, since a different sized view and different layout would be in use.
You have either not set the iPad xib, so the app can't set up a window with root view controller, or you haven't set up a valid iPad xib, so it isn't loading at all, with the same results.
If you just want the app to run in the mini-iPhone window with the 2x button, leave it as an iPhone only app.
If you are getting "The application is expected to have its root view set at the end of application start." there are a number of possibilities. Clearly, that is the problem, since you have a black screen with nothing in it...
Check out this SO question: Application windows are expected to have a root view controller at the end of application launch warning Rob Mayoff has a good description of what should be happening when your application initializes.
Also, linked to in the above post, is this post wherein there are an additional 35 answers with various scenarios of what could be happening.
Beyond browsing through those links, you will need to post up additional code and/or descriptions of how your nibs are wired up for anyone to help you--as evidenced by the myriad ways it is possible to cripple the initialization sequence.

ViewController screen to download database before launch application

I used the storyboard to create my application, where the initial View is an TabBarController.
But the first time the application starts I download the database (4Mb). So, my splash screen is displayed until the download is over, because the download is done in AppDelegate. I would like to change it and display a View to the user indicating that a download is being done, not to get the impression that the application crashed.
I tried this in didFinishLaunchingWithOptions: but doesn't work:
LoadViewController *loadView = [[LoadViewController alloc] init];
[self.window makeKeyAndVisible];
[self.window addSubview:[loadView view]];
Thanks in advance.
I am not sure if this will meet your needs but I used MBProgressHUD to handle some display while uploading data to a server, maybe you could do something like the same with your download of the database.
HUD = [[MBProgressHUD alloc] initWithView:[self view]];
[[self view] addSubview:HUD];
HUD.dimBackground = YES;
HUD.delegate = self;
[HUD showWhileExecuting:#selector(taskToDownloadDatabase) onTarget:self withObject:nil animated:YES];
This would allow you to show the user some progress that something is happening and when the database is fully downloaded initialize your view.
Why not download the database outside the appDelegate, then share it with the appdelegate? Or Perhaps do:
[self performSelector#selector(downloadDatabase) afterDelay:1...];
so the view loads first?

objective-c : How to move from AppDelegate in Universal app?

I am developing a Universal app where I have
imageTracker_iPhone.xib
imageTracker_iPad.xib
imageTracker.h
imageTracker.m
I want to move from AppDelegate_iPhone to imageTracker. I am doing this in didFinishLaunchingWithOptions but its not working before this code I was using
imageTracker *vRDi = [[imageTracker alloc] initWithNibName:#"imageTracker_iPhone" bundle:nil];
[self.view addSubview:vRDi.view];
but it gave error request for member 'view' in something not a structure or union
. Even if code is like
[window addSubview:vRDi.view];
now The function is like below and its not working. I want to move from AppDeligate to imageTracker. please help
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[window addSubview:imageTracker.view];
[self.window makeKeyAndVisible];
return YES;
}
In this case It does not move to imageTracker_iPhone because did not tell any where to move to this file, so want to know that HOw to tell that which file to move either imageTracker_iPhone or imageTracker_iPad.
You probably want to set the delegate window's rootViewController to make your first controller active. (If you create a new test app from a single controller, non-storyboard template, you can see the kind of code that's needed in didFinishLaunchingWithOptions:.)
Edit: Actually, it's even easier than that. If you specify a universal app when creating a single view controller project, it creates the exact code to test which kind of device and load the matching .xib file. (Xcode 4.2, at least.)
your code should be something like this
imageTracker *vRDi;
Bool isiPhone = UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone;
if(isiPhone)
vRDi = [[imageTracker alloc] initWithNibName:#"imageTracker_iPhone";
else
vRDi = [[imageTracker alloc] initWithNibName:#"imageTracker_iPad";
and make sure that your connect view outlet in both xib's and the file owner is "imageTracker" Class.

Stop using Interface Builder

When coding iPhone applications, I've never used Interface Builder myself; thought it was too complicated and useless.
Problem is, I decided to pick up an abandoned opensourced project on GitHub which uses Interface Builder, and I can't seem to stop using it.
It seemed to be that I should start from scratch on programatically coding views, so I went to the application's Info.plist and deleted the NSMainXIBFile (or something like that) related keys.
Once I did so, the application launches, and a message is printed by the console: Applications are expected to have a root view controller at the end of application launch.
I can't seem to find the issue here; I have done:
NSArray *controllers = [NSArray arrayWithObjects:controller1, controller2, nil];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:controllers];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];
Am I skipping some key step on stopping using Interface Builder or is my error at the code itself?
You shouldn't add the tab bar controller's view to the window as a subview. You should set it as the window's root view controller instead:
window.rootViewController = tabBarController;
You need to properly assign the property window.rootViewController, not add the tab bar controller as a subview.
self.window.rootViewController = tabBarController;
Try
#synthesize window = _window;
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[self.window makeKeyAndVisible];
And then add a subview to the window.

Problem with getting a modalViewController to appear

I've been fighting with this for hours. I've searched around everywhere and just can't seem to find the solution to my problem. I'm pretty sure I'm just lacking some key concepts here.
My AppDelegate (didFinishLaunching) basically sets up my window and invokes RootViewController:
// create our window
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
[window setBackgroundColor:[UIColor blackColor]];
// create our rootviewcontroller
RootViewController *controller = [[RootViewController alloc] init];
// add our rootviewcontroller's view to our window
[window addSubview:controller.view];
// controller is now owned by window's view
[controller release];
// show us to the world
[window makeKeyAndVisible];
When I add controller.view as window's subview, my understanding is that RootVC's loadView will automatically get called.
In RootVC loadView, I create a tabBarController, each tab having a navigationController and it's own viewController. All that is working fine.
In RootVC viewDidLoad, I'm checking to see if this is the first time a user is running this app, and if so, I want to throw up a modal welcome screen. This is the part I'm having trouble with.
I'd like to keep as much code out of the RootVC's viewDidLoad method, and ideally would be able to accomplish what I want with this:
WelcomeViewController *welcome = [[WelcomeViewController alloc] init];
[self presentModalViewController:welcome animated:true];
[welcome release];
Obviously this isn't working. WelcomeVC's loadView hasn't been run yet because I haven't explicitly set it's view property. I've played around with a bunch of different solutions (welcome.view - [[UIView....], using WelcomeVC's init method to set self.view) but I just can't seem to get that modal to pop up.
How should I accomplish what I'm looking for? What are the best practices, and what's the best solution to keep my code tight and tidy?
I'm stuck, so hopefully your solution will allow me to continue developing my app!
Although the problem is not so simple, the solution is. You have to wait until the main view appears. So check the condition and present your modal view in viewDidAppear method, not in viewDidLoad method.