Subclass of uiview problems

Discussion in 'iOS Development' started by hodgey87, Oct 16, 2010.

  1. hodgey87

    hodgey87 New Member

    Oct 21, 2007
    Likes Received:
    Hi Everyone,

    Im having some problems with a view i have, it contain a few drawings squares, circles etc. Whenever the app loads it only shows this view and not the main controller view where i have buttons etc. Is there a way to set this otherview into the background of the mainviewcontroller without covering the buttons.

    This is the appdelegate where i think the problem is:
    mainViewController.view.frame = [UIScreen mainScreen].applicationFrame;
    	[window addSubview:[mainViewController view]];
    	MainView *view = [[MainView alloc] initWithFrame:[window frame]];
    	[window addSubview:view];
    	[view release];
        [window makeKeyAndVisible];
    Can you re size a view at all? Or if someone could point me in the right direction, I've been trying to work this out the past 2 days.

  2. Axis

    Axis Super Moderator Staff Member

    Dec 2, 2007
    Likes Received:
    iPhone 4S (White)
    You correctly added the view controller's view as a subview of the window, but you immediately added another subview, of the same size, to the window, covering up the first view.

    If you want the second view to be smaller, set a different frame.

    In order to get the layout you want, you may have to add the second view as a subview of the view controller's view and then perhaps alter the z-level of the subviews.

Share This Page