【问题标题】:how do i create a sliding menu in xcode iphone like the main android menu sliding menu?我如何在 xcode iphone 中创建一个滑动菜单,就像主 android 菜单滑动菜单一样?
【发布时间】:2011-07-29 20:22:57
【问题描述】:

我一直在网上寻找标题中描述的滑动菜单示例。我只需要知道我应该查看 iphone 库中的哪些项目来完成此操作,我不想占用别人的时间让他们写出代码,但如果有一点指导,将不胜感激?

【问题讨论】:

    标签: iphone xcode cocoa-touch


    【解决方案1】:

    我们在我们的 iphone 应用程序中创建了一个滑动抽屉,我们使用以下过程完成了这项工作:

    1. 在 Interface builder 的 View Controller 中创建一个 UIView 对象。
    2. 在您的视图控制器中创建 UIView 的对象(不要忘记在 .h 文件中创建它(IBOutlet))
    3. 类似地在界面构建器和视图控制器中创建一个按钮,以及它的操作方法。
    4. 将头文件中的对象与界面生成器中的对象链接

    在视图控制器的 viewDidLoad 中设置要滑动的视图的框架,带有按钮

        - (void)viewDidLoad {
    [super viewDidLoad];
    
    toOpenView.frame = CGRectMake(self.view.frame.size.width, toOpenView.frame.origin.y, 0, toOpenView.frame.size.height);
    

    }

    在按钮的点击事件中添加以下代码

        -(IBAction)onOpenButtonClick:(id)sender
        {
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.8];
    
    if (toOpenView.frame.origin.x == self.view.frame.size.width/2)
    {
    
        toOpenView.frame = CGRectMake(self.view.frame.size.width, toOpenView.frame.origin.y, 0, toOpenView.frame.size.height);
        openButton.frame = CGRectMake((self.view.frame.size.width - openButton.frame.size.width), openButton.frame.origin.y, openButton.frame.size.width, openButton.frame.size.height);
    
    }
    else
    {
        toOpenView.frame = CGRectMake(self.view.frame.size.width/2, toOpenView.frame.origin.y, self.view.frame.size.width/2, toOpenView.frame.size.height);
        openButton.frame = CGRectMake((toOpenView.frame.size.width - openButton.frame.size.width), openButton.frame.origin.y, openButton.frame.size.width, openButton.frame.size.height);
    }
    [UIView commitAnimations];
    

    }

    【讨论】:

      【解决方案2】:

      This 希望能帮助您入门。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-09-02
        • 1970-01-01
        相关资源
        最近更新 更多