iPhone Modal View Smaller that the screen

后端 未结 5 1042
一生所求
一生所求 2021-01-31 06:23

I\'m trying to do something that shouldn\'t be that complicated, but I can\'t figure it out. I have a UIViewController displaying a UITableView. I want to present a context menu

5条回答
  •  北海茫月
    2021-01-31 07:01

    wangii

    Thats pretty much the solution I found. I load the view with loadNibNamed and then just add it on top with addSubView, like this:

    //Show a view on top of current view with a wait indicator. This prevents all user interactions.
    -(void) showWaitView{
        NSArray* nibViews =  [[NSBundle mainBundle] loadNibNamed:@"WaitView" owner:self options:nil];
    #ifdef __IPHONE_2_1
        waitView = [ nibViews objectAtIndex: 0];
    #else
        waitView = [ nibViews objectAtIndex: 1];
    #endif          
        CGFloat x = self.view.center.x - (waitView.frame.size.width / 2);
        CGFloat y = self.view.center.y - (waitView.frame.size.height / 2);
        [waitView setFrame:CGRectMake(x,y,waitView.bounds.size.width,waitView.bounds.size.height)];
        [self.view addSubview:waitView];    
    }
    

    Could you elaborate on points 3 and 4?

    What I did to give the view the round rect aspect is put it inside a round rect button.

    This code will actually allow you to have a small floating view, but if the view is smaller that its parent, the user could interact with the visible part of the parent.

    In the end I create my view with the same size, but kept the code just in case.

    Gonso

提交回复
热议问题