Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to load xib of a viewcontrolller from a custom method?
    primarykey
    data
    text
    <p>In my three 20 project i am calling and sending some parameters to a method of my view controller using map object. I am passing the image name through parameter to my view controller. I have bound a xib file with my view controller . my xib contains a toolbar at the top and uiimage view. My problem is that when i pass parameter to my custom method and load my xib file in the next line then my view controller's view is not displayed on the screen. I am receiving the parameter in my custom method but unable to load xib on the screen. I am using the following custom method</p> <pre><code>-(void)loadImageWithName:(NSString *)img { PhotoView *vw = [[PhotoView alloc] initWithNibName:@"PhotoView" bundle:nil]; UIImage *tempImage = [UIImage imageNamed:img]; [vw.drawImage setImage:tempImage]; [self presentModalViewController:vw animated:YES]; } </code></pre> <p>When i do this i can see my xib loaded on the window.</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[TTURLRequestQueue mainQueue] setMaxContentLength:0]; TTNavigator *navigator = [TTNavigator navigator]; navigator.window = _window; TTURLMap *map = navigator.URLMap; [map from:@"tt://appPhotos" toSharedViewController:[PhotoViewController class]]; [map from:@"tt://photo" toSharedViewController:[PhotoView class]]; [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://photo"]]; [_window makeKeyAndVisible]; return YES; } </code></pre> <p>But when i do this my xib does not load and i see only a white screen</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[TTURLRequestQueue mainQueue] setMaxContentLength:0]; TTNavigator *navigator = [TTNavigator navigator]; navigator.window = _window; TTURLMap *map = navigator.URLMap; [map from:@"tt://appPhotos" toSharedViewController:[PhotoViewController class]]; [map from:@"tt://photo/(loadImageWithName:)" toSharedViewController:[PhotoView class]]; [navigator openURLAction:[TTURLAction actionWithURLPath:@"tt://photo/myphoto.png"]]; [_window makeKeyAndVisible]; return YES; } </code></pre> <p>This is the issue that i am facing right now.</p> <p>I solved the above issue by using</p> <pre><code>- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [[TTURLRequestQueue mainQueue] setMaxContentLength:0]; TTNavigator *navigator = [TTNavigator navigator]; navigator.window = _window; TTURLMap *map = navigator.URLMap; [map from:@"tt://appPhotos" toSharedViewController:[PhotoViewController class]]; [map from:@"tt://photo/detail?name=(initWithImage:)" toSharedViewController:[PhotoView class]]; [navigator openURLAction:[TTURLAction actionWithURLPath:[NSString stringWithFormat:@"tt://photo/detail?name=%@",@"level_me_up_small.png"]]]; [_window makeKeyAndVisible]; return YES; } </code></pre> <p>But still there are two probe.</p> <ol> <li>i am getting extra space between my toolbar at top and uiimageview. </li> </ol> <p>2.UIImageView image is not changed to instant_poetry_small.png.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload