开发者

How to display a view of a particular size(not full screen) with in a view in objective-c iPhone?

I want to call a particular view in my xcode project. Actually, I have created a navigation based application. I have added a button in the navigation bar. Now I want, when somebody click on that button then a particular view of button list open ask for user to click a particular button. The solution which I can think for it is to create a view and add it on the button's click. But I am not able to find how to achieve this. Help me out开发者_Python百科?


        view *optionsController = [[view alloc] 
                                                   initWithNibName:@"view" 
                                                   bundle:nil];

        CGRect optionsFrame = optionsController.view.frame;
        optionsFrame.origin.x = 10;
        optionsFrame.size.width = 220;
        optionsFrame.origin.y = 123;

        //
        // For the animation, move the view up by its own height.
        //
        optionsFrame.origin.y += optionsFrame.size.height;

        optionsController.view.frame = optionsFrame;

        [self.superview addSubview:optionsController.view];


        [UIView beginAnimations:nil context:nil];

        optionsFrame.origin.y -= optionsFrame.size.height;
        optionsController.view.frame = optionsFrame;

        [UIView commitAnimations];


Create an UIView object set the frame property as much you require not the full size Now create button add this as sunview to your newly created UIView.

Now Add your UIView as the subview in your main view.


I recommend to look into UIActionSheet. This sounds like a perfect use case for it.


hey sanchit.. simply add the button either from xib or programmaticaly and get a selector to that button (add IBAction or use[buuton addSelector:]) and in that method do something like this.

[self.view addSubview:dummyView];

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜