Question

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.

Was it helpful?

Solution

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.)

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top