iphone开发中,添加了UINavigationBar,但是在左右两边只能添加一个方形的按钮。
如果要在左边添加一个带箭头的按钮,和ios界面统一,可以参考下面代码:

UINavigationItem *item = [navigationBar.items objectAtIndex:0];
UINavigationItem *back = [[UINavigationItem alloc] initWithTitle:@"返回"];
NSArray *items = [[NSArray alloc] initWithObjects:back,item,nil];
[navigationBar setItems:items];
[back release];
[items release];


这样左边按钮就出来了,右边加的按钮会保留。
点击左边按钮会消失,真的是返回了,可以自定义事件:

添加事件:

[navigationBar setDelegate:self];


定义事件:

- (BOOL) navigationBar:(UINavigationBar *)navigationBar
        shouldPopItem:(UINavigationItem *)item{
    //点击back按钮之后的操作
    NSLog(@"test click");
    return FALSE;
}




原创内容如转载请注明:来自 阿权的书房
收藏本文到网摘
电子商务 Homepage
2012/02/23 11:34
好。学习了。
分页: 1/1 第一页 1 最后页
发表评论
表情
emotemotemotemotemotemotemotemotemotemotemotemotemot
emotemotemotemotemotemotemotemotemotemotemotemot
打开HTML 打开UBB 打开表情 隐藏
昵称   密码   游客无需密码
网址   电邮   [注册]
               

验证码 不区分大小写
 

阅读推荐

服务器相关推荐

开发相关推荐

应用软件推荐