简体   繁体   English

如何在iPhone中放置菜单按钮

[英]how to place menu button in iphone

i need to place menu button in iphone. 我需要在iPhone中放置菜单按钮。

i have some touch with android. 我和android有一些联系。

In android i display like this by pressing menu. 在我的Android显示像这样按菜单。

Is it possible to handle iphone menu button. 是否有可能处理iPhone菜单按钮。

if it is not where can i place these. 如果不是,我可以在哪里放置这些。

Thank u in advance. 预先谢谢你。

I think with Xcode and Interface Builder (iPhone's development platform), getting this task done would be even simpler. 我认为使用Xcode和Interface Builder(iPhone的开发平台),完成此任务将更加简单。

As a brief introduction to iPhone app's UI design, to place this tab bar (as you put it, the menu) on a view, all you need to do is pick up a tab bar from the library and place it on a nib file's view. 作为iPhone应用程序UI设计的简要介绍,要将这个标签栏(如您所说的,菜单)放在视图上,您​​需要做的就是从库中拾取一个标签栏并将其放在nib文件的视图上。 。 You can also connect such a tab bar with some codes responsible for internal logic by simply clicking and dragging. 您也可以通过单击并拖动将这样的选项卡栏与负责内部逻辑的某些代码连接起来。 It's simple. 这很简单。

btw, a nib file is just some file format Xcode and Interface Builder use to hold the UI data. 顺便说一句,nib文件只是Xcode和Interface Builder用来保存UI数据的某种文件格式。

iPhones don't have a dedicated slide out menu - everything is on the screen at all times, and there are no purpose built buttons (like back and home). iPhone没有专用的滑出菜单-随时都在屏幕上显示所有内容,并且没有特制的按钮(例如后退和首页)。

You should either always show your actions on the screen, or if they are unimportant or infrequent, hide them behind another action button (like a + or wrench icon). 您应该始终在屏幕上显示您的操作,或者如果它们不重要或不常见,请将其隐藏在另一个操作按钮(例如+或扳手图标)后面。

You should use images same as menu items and put custom button over the images.This is the only way to show menu as you want. 您应该使用与菜单项相同的图像,并在图像上放置自定义按钮。这是根据需要显示菜单的唯一方法。

Iphone sdk provides tabBar and toolBar, you also can use these in customize forms.This is the correct way to making menu.Iphone design pattern having lot of strengths over android so you can make every thing in Iphone easily but you cant make every thing in android same as iPhone.Iphone having international standards so must use iPhone's controls. Iphone sdk提供tabBar和toolBar,您也可以在自定义窗体中使用它们。这是制作菜单的正确方法。Iphone设计模式比android有很多优势,因此您可以轻松地在Iphone中制作所有东西,但不能在Iphone中制作任何东西。与iPhone相同的android。iPhone具有国际标准,因此必须使用iPhone的控件。

use the round rect button and change the property into custom place the image as the background image of the button do this for more menu item in your home page. 使用圆角矩形按钮并将属性更改为自定义位置,将图像作为按钮的背景图像进行此操作,以使主页中有更多菜单项。

this is the way i do the menu item....... 这是我做菜单项的方式.......

.h 。H

IBOutlet UIScrollView *scrollView;

@property ( nonatomic , retain )  IBOutlet UIScrollView *scrollView;

-(void)AppleVijayAtFacebookDotCom:(id)sender;

-(void)createMenuWithButtonSize:(CGSize)buttonSize withOffset:(CGFloat)offset noOfButtons:(int)totalNoOfButtons;

.m .m

@synthesize scrollView;



-(void)AppleVijayAtFacebookDotCom:(id)sender{


    NSLog(@"AppleVijayAtFacebookDotCom called");


    UIButton *button=(UIButton *)sender;


    if (button.tag == 0) {

        NSLog(@"hey have clicked first button, this is my tag : %i \n\n",button.tag);
    }
    else if (button.tag == 1) {

        NSLog(@"hey have clicked second button, this is my tag : %i \n\n",button.tag);

    }
    // ......like this

    NSLog(@"button clicked is : %iBut \n\n",button.tag);



}       



-(void)createMenuWithButtonSize:(CGSize)buttonSize withOffset:(CGFloat)offset noOfButtons:(int)totalNoOfButtons{

for (int i = 0; i < totalNoOfButtons; i++) {

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];

    [button addTarget:self action:@selector(AppleVijayAtFacebookDotCom:) forControlEvents:UIControlEventTouchUpInside];

        //[button1 setImage:[UIImage imageNamed:@"Button.png"] forState:UIControlStateNormal];//with image

        //OR

    [button setTitle:[NSString stringWithFormat:@"%iBut",i] forState:UIControlStateNormal];//with title

    button.frame = CGRectMake(i*(offset+buttonSize.width), 8.0, buttonSize.width, buttonSize.height);

    button.clipsToBounds = YES;

    button.showsTouchWhenHighlighted=YES;

    button.layer.cornerRadius = 10;//half of the width

    button.layer.borderColor=[UIColor redColor].CGColor;

    button.layer.backgroundColor=[UIColor blackColor].CGColor;

    button.layer.borderWidth=2.0f;

    button.tag=i;

    [self.scrollView addSubview:button];

}

self.scrollView.contentSize=CGSizeMake((buttonSize.width + offset) * totalNoOfButtons, buttonSize.height);

    //self.navigationItem.titleView=self.scrollView;//if u have navigationcontroller then enable this line

} }

Dont forget to connect the scrollView in interface builder 不要忘记在界面构建器中连接scrollView

while creating the scrollview in IB make sure ur scrollView height is 44.which is default to navigation bar.so it will look nice. 在IB中创建scrollview时,请确保您的scrollView高度为44。默认为导航栏。这样看起来会很好。

in viewDidLoad call 

[self createMenuWithButtonSize:CGSizeMake(70.0, 30.0) withOffset:20.0f noOfButtons:30];

OUTPUT 输出值

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM