tags:

views:

25

answers:

2

Hello everyone

I have an UIView (320*300 the view of an UIViewController), I hope to display UINaviationCotroller and control the navigation within this view size.

Is it possible?

Thanks

interdev

A: 

yes.. why do you think it wouldn't be? It is probably non-standard but technically it can be done

Aaron Saunders
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];navController=navigationController;navController.navigationItem.title = @"abc"; [self presentModalViewController:navController animated:NO];
above are my codes. myViewcontroler.view size is 320*300, but unfortunately, navController still appeared as full screen
A: 

Below you'll find out a snippet of code that does it. But let me give you a word of wisdom. Don't do it. Avoid at all costs. Apple doesn't recommend doing that. You will have nightmares and will be busy patching edge cases. It worked well in 3.x, with iOS 4 you'll have to work around a lot of special cases.

- (void) _adjustViewControllerforTicker {
 TickerView* vv = [ApplicationContext getTickerView];
if ([PreferenceDataModel isTickerOn]&& self.navigationController.view.frame.origin.y==0) {

    CGRect tableRect = self.tableView.frame;
    self.tableView.frame = CGRectMake(tableRect.origin.x,tableRect.origin.y, tableRect.size.width, tableRect.size.height -20);
    UINavigationController *nav = self.navigationController;
    CGRect gframe = CGRectOffset(self.navigationController.view.frame, 0, 20);
    self.navigationController.view.frame = gframe;
    if (!vv) {
        vv = [[TickerView alloc] initWithFrame:CGRectMake(0, 0, 480, 20)];

        [nav.view addSubview:vv];
        [vv release];
        self.tableView.contentInset=UIEdgeInsetsMake(0,0,20.0,0.0);
    }
}   
if (![PreferenceDataModel isTickerOn]) {
    self.tableView.contentInset= UIEdgeInsetsZero;
    if (vv){
        [vv removeFromSuperview];
        vv=nil;
    }
}

}

bioffe