Resolved costum 'header' and 'footer'

Discussion in 'iOS Programming' started by DennisBlah, Dec 16, 2014.

  1. DennisBlah, Dec 16, 2014
    Last edited: Dec 17, 2014

    DennisBlah macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #1
    Hi all,

    I'm making some apps lately and I'm facing some issue's while navigation through views with consistency of my 'views'.

    On all my views I make a UIView that contains my buttons.. and a UIView that acts like an 'header' with an image and some title bottom right just below the image.

    Is there an way to make these 'header' and 'footer' in an UIViewController class, and load these INSIDE another view ?

    So where I want to go is, making this 'header' and 'footer' once so I can include these in my views.

    The reason I'm doing it like this is, the default Navigationcontroller class is too short for my image, and adjusting it with code is just ... not simple enough for quick editing.

    AND I just don't seem how to include an 'footer' in my controller so my other viewcontrollers will be between the header and footer.

    Hopefully someone can help me out here, with an sample or an tutorial ?

    I been looking around but.. it just does not make sense to me.

    Thanks!
     
  2. Punkjumper macrumors member

    Joined:
    Jan 12, 2013
    #2
    I would consider making your baseViewController and set up the footer and header views exactly how you want them. In the baseViewController I would probably place an empty center view that would contain the content that is different on each screen. Expose the contentView as a property.

    Then all your other viewControllers would be a subclass of baseViewController. Then all your subclass viewControllers could assign that centerView with their custom content and you have to touch the header and footer views.
     
  3. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #4
    That is exactly what I'm trying to do, however I can't get the other viewcontrollers a 'sub' into the base.
    How do I do this, and how can I then navigate from one 'sub viewcontroller' to another and still keep the baseview ?

    It's not an toolbar, it's a view with custom icons and background which will be changed based on the settings on the database on the web.
    Same thing for the 'header'.

    I can get the header size bigger like:
    Code:
    //Resize navigationBar
        self.navigationBar.frame = CGRectMake(0,0,self.view.frame.size.width, 150);
    //Load background header
        UIImage *image = [UIImage imageNamed:[mySettings objectForKey: @"headerBG"]];
        UIImageView *imgView = [[UIImageView alloc] initWithImage:image];
        imgView.frame = CGRectMake(0,0,self.navigationBar.frame.size.width,self.navigationBar.frame.size.height);
        [self.navigationBar addSubview:imgView];
    //Load header image
        image = [UIImage imageNamed:[mySettings objectForKey: @"header"]];
        imgView = [[UIImageView alloc] initWithImage:image];
        imgView.frame = CGRectMake((self.navigationBar.frame.size.width / 2) - 90,0,180,150);
        [self.navigationBar addSubview:imgView];
    
    From there I can navigate through the app and reserve the size and background by calling it in the 'navigationviewcontroller' viewdidappear, because it's being resetted everytime. However this is giving a little glitch when rotating my orientation.

    Any help would be appriciated
     
  4. Sean7512 macrumors 6502a

    Joined:
    Jun 8, 2005
    #5
  5. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #6
    I will read through this later tonight.
    But actually I want to use navigationcontroller
    So my header and footer will be initialised once and setup once.
    Like html and iframe
    A html page, with header, iframe, footer
    And everything gets loaded in the iframe without reloading the header and footer
     
  6. Punkjumper macrumors member

    Joined:
    Jan 12, 2013
    #7
    You never directly I itialize the base controller. When you create your firstContoller it is if type BaseViewCintroller not UIViewcontroller. Then you make secondView controller also a subclass of baseViewController and switch between them like normal.

    all the properties that you want shared between all your views get added to the base controller and unique stuff gets added in your subclasses.
     
  7. DennisBlah thread starter macrumors 6502

    DennisBlah

    Joined:
    Dec 5, 2013
    Location:
    The Netherlands
    #8
    Hi all,

    I been playing around, googling around and throwing codes around up and down.

    I now got 1 'rootViewController' where I build up my 'template'.
    In here I set an 'containerView'.

    With seque's and a seque UIStoryboardSeque object, I now load other viewcontrollers in the containerview :D

    Thanks for everything all!
     

Share This Page