0

I have a project which is created by storyboard, and the way to connect and shift each viewcontroller in the project is by navigation bar (back bottom). I would like to apply metaio sdk which is written by xib in my project. The sdk works perfectly but the problem is the xib doesn't contain navigation bar. The app is unable to go back to previous page. I have tried to covert xib into storyboard but didn't success.

I have ARViewController.h/m/xib

#import <UIKit/UIKit.h>
#import <metaioSDK/MetaioCloudPlugin/MetaioCloudPluginViewController.h>

@interface ARViewController : MetaioCloudPluginViewController
{
bool    m_useLocationAtStartup; //!< Flag to indicate if we should use the location at startup
}

- (IBAction)onBtnClosePushed:(id)sender;

@end

.m

#import "ARViewController.h"
#import "ASImageSharingViewController.h"

@implementation ARViewController

#pragma mark - View lifecycle


- (void) viewDidLoad
{
[super viewDidLoad];

// use this call to move the radar position
if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
{
    [self setRadarOffset:CGPointMake(-16, -20) scale:0.825f anchor:ANCHOR_TR];
}
else
{
    [self setRadarOffset:CGPointMake(-4.5, -20) scale:0.55f anchor:ANCHOR_TR];
}


// add the popup view to the view hierarchy if it is not present there already.
if( ![self.objectContextView  superview] )
{
    // we add it to the screen
    [self.view addSubview:self.objectContextView];

    [self.objectContextView setHidden:YES];
}
}


#pragma mark - react to UI events

// Close the UIViewcontroller on pushing the close button.
- (IBAction)onBtnClosePushed:(id)sender
{
[self dismissViewControllerAnimated:YES completion:Nil];
}

#pragma mark - @protocol MetaioCloudPluginDelegate

/** 
 * Provide the channel number that should be opened by the plugin 
 * In order to get your channel ID, please signup as a developer on http://www.junaio.com/developer
 * and create your own channel.
 *
 * If you want to use a location based channel, be sure to return 'YES' for (BOOL) shouldUseLocation,
 * otherwise 'NO'.
 */
- (NSInteger) getChannelID
{
// TODO: fill in your channel ID here.

bool loadLocationBasedChannel = false;
if( loadLocationBasedChannel )
{
    // set locationAtStartup to YES, because we're loading a location based channel
    // that needs the location at the first request
    m_useLocationAtStartup = YES;
    return 4796;    // Wikipedia EN channel
}
else
{
    // set locationAtStartup to NO, because we don't need a location for the first request
    // This is the default for all AREL XML channels that don't provide location based content
    m_useLocationAtStartup = NO;
    //return 174470;        // AREL instant tracker
    return 214841;
}
}

/** Optional
 *
 * return YES if the application should support location
 * If you return NO here, your application will never access the location sensors.
 * Most scan channels don't need a location, so NO can be returned here.
 */
- (BOOL) shouldUseLocation
{
return YES;
}

/** Optional
 *
 * return YES if the application should activate location sensors at startup
 * This will cause the application requesting permission at startup
 * Return YES here if you are using a location based channel that needs location at startup
 * Returning NO will cause the request to the server having no location
 */
- (BOOL) shouldUseLocationAtStartup
{
return [self shouldUseLocation] && m_useLocationAtStartup;
}

///** Optional
// *
// * return YES to cache downloaded files
// * During the development phase it makes sense to return NO here,
// * if the channel content changes a lot.
// */
//- (BOOL) shouldUseCache
//{
//  return YES;
//}

#pragma mark - Extras

/** Default implementation for Sharing a screenshot
 * 
 * Feel free to adjust the source of ASImageSharingViewController to adjust its behavior or integrate the Facebook SDK
 */
- (void) openSharingViewController: (UIImage*) imageToShare
{
ASImageSharingViewController* controller = [[ASImageSharingViewController alloc] initWithNibName:@"ASImageSharingViewController" bundle:nil];
controller.imageToPost = imageToShare;
[self presentViewController:controller animated:YES completion:Nil];
//[controller release]; 
}  
@end

What I have done to shift xib to storyboard are: 1. create empty unviewcontroller and delete default view. 2. copy the view from ARViewController.xib to new unviewcontroller 3. set ARViewController as a custom class in new unviewcontroller

However, when I run the project it still run in xib file not the unviewcontroller in storyboard.

My questions are:

  1. What is the easiest way to have a navigation bar in this view? Convert xib to storyboard or put a navigation bar directly to the xib?

  2. How to covert this xib to storyboard so that the navigation bar can work in this page?

  3. How to put a navigation bar with back bottom to the xib? (I'm using Xcode 5)

bneely
  • 9,083
  • 4
  • 38
  • 46
Richard
  • 125
  • 1
  • 9
  • Show your `appDelegate.m`. – Toseef Khilji Mar 06 '14 at 05:49
  • my question is similar with this http://stackoverflow.com/questions/19594827/call-navigationcontroller-xib-from-viewcontroller-storyboard – Richard Mar 06 '14 at 06:39
  • So than whats problem now, there is explanation how to use it. – Toseef Khilji Mar 06 '14 at 06:42
  • according to the best answer of above question, I still do not understand how to do that. where i should create instance of the xib viewController with initWithNibName, and then where i should put the code to push this controller instance on navigation controller?? – Richard Mar 06 '14 at 06:48
  • Check http://www.fantageek.com/481/how-to-programmatically-set-initial-view-controller-using-storyboard/ http://stackoverflow.com/questions/20337425/creating-navigation-bar-programmatically-with-storyboard – Toseef Khilji Mar 06 '14 at 06:51

1 Answers1

1

You should use UINavigationController this the answer of your all question.

Toseef Khilji
  • 17,192
  • 12
  • 80
  • 121