UIbarbuttonItem *btnSave = [[UIbarbuttonItem alloc] initWithTitle:@"Save" style:UIbarbuttonItemStylebordered target:self action:@selector(save_Clicked:)]; self.navigationItem.rightbarbuttonItem = btnSave; [btnSave release]; UIbarbuttonItem *btnCancel = [[UIbarbuttonItem alloc] initWithTitle:@"Cancel" style:UIbarbuttonItemStylebordered target:self action:@selector(save_Clicked)]; self.navigationItem.leftbarbuttonItem = btnCancel; [btnCancel release];
我的问题是如何在左侧栏按钮项旁边添加另一个按钮.
提前致谢
像这样的东西:
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0,250,44)];tools.tintcolor = [UIcolor clearcolor];[tools setTranslucent:YES];NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:9];UIImage *myImage = [UIImage imagenamed:@"AL_HomeMod_Icon.png"];UIbutton *mybutton = [UIbutton buttonWithType:UIbuttonTypeCustom];[mybutton setimage:myImage forState:UIControlStatenormal];mybutton.showstouchWhenHighlighted = YES;mybutton.frame = CGRectMake(0.0,0.0,myImage.size.wIDth,myImage.size.height);[mybutton addTarget:self action:@selector(clickVIEwHomeMod) forControlEvents:UIControlEventtouchUpInsIDe];UIbarbuttonItem *bi = [[UIbarbuttonItem alloc] initWithCustomVIEw:mybutton];[buttons addobject:bi];[bi release];myImage = [UIImage imagenamed:@"AL_History_Icon.png"];mybutton = [UIbutton buttonWithType:UIbuttonTypeCustom];[mybutton setimage:myImage forState:UIControlStatenormal];mybutton.showstouchWhenHighlighted = YES;mybutton.frame = CGRectMake(0.0,myImage.size.height);[mybutton addTarget:self action:@selector(clickVIEwHistory) forControlEvents:UIControlEventtouchUpInsIDe];bi = [[UIbarbuttonItem alloc] initWithCustomVIEw:mybutton];[buttons addobject:bi];[bi release];myImage = [UIImage imagenamed:@"AL_RX_Icon.png"];mybutton = [UIbutton buttonWithType:UIbuttonTypeCustom];[mybutton setimage:myImage forState:UIControlStatenormal];mybutton.showstouchWhenHighlighted = YES;mybutton.frame = CGRectMake(0.0,myImage.size.height);[mybutton addTarget:self action:@selector(clickVIEwCustomPopVIEw2) forControlEvents:UIControlEventtouchUpInsIDe];bi = [[UIbarbuttonItem alloc] initWithCustomVIEw:mybutton];[buttons addobject:bi];[bi release];myImage = [UIImage imagenamed:@"AL_User_Icon.png"];mybutton = [UIbutton buttonWithType:UIbuttonTypeCustom];[mybutton setimage:myImage forState:UIControlStatenormal];mybutton.showstouchWhenHighlighted = YES;mybutton.frame = CGRectMake(0.0,myImage.size.height);[mybutton addTarget:self action:@selector(clickVIEwCustomPopVIEw:) forControlEvents:UIControlEventtouchUpInsIDe];bi = [[UIbarbuttonItem alloc] initWithCustomVIEw:mybutton];[buttons addobject:bi];popbutton = mybutton;[bi release];// stick the buttons in the toolbar[tools setItems:buttons animated:NO];[buttons release];// and put the toolbar in the nav barself.navigationItem.rightbarbuttonItem = [[UIbarbuttonItem alloc] initWithCustomVIEw:tools];[tools release];
希望有所帮助
Pondd
总结以上是内存溢出为你收集整理的iphone – 在导航栏中添加栏按钮项全部内容,希望文章能够帮你解决iphone – 在导航栏中添加栏按钮项所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)