Ios 在左侧的导航栏上同时添加图像和文本

Ios 在左侧的导航栏上同时添加图像和文本,ios,objective-c,uinavigationbar,Ios,Objective C,Uinavigationbar,我在appdelegate类中尝试过这段代码,因为我希望它贯穿整个项目,它用于显示图像,但它在中间显示我需要的文本,而我无法显示 有人能建议我如何在iOS中的导航栏左侧同时显示图像和文本吗?为什么要将imageview设置为navigation topItem titleview 替换 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptio

我在appdelegate类中尝试过这段代码,因为我希望它贯穿整个项目,它用于显示图像,但它在中间显示我需要的文本,而我无法显示


有人能建议我如何在iOS中的导航栏左侧同时显示图像和文本吗?为什么要将imageview设置为navigation topItem titleview

替换

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
UINavigationController *nav=[[UINavigationController alloc] initWithRootViewController:self.viewController];

// CHANGE COLOR TO BLACK

nav.navigationBar.tintColor = [UIColor blackColor];

// ADDING IMAGE TO NAVIGATION BAR
UIImage *image = [UIImage imageNamed:@"logo_36.png"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[nav.navigationBar.topItem setTitleView:imageView];

self.window.rootViewController = nav;
[self.window makeKeyAndVisible];  

return YES;
}
使用nav.navigationbar.topItem.LeftBarButtonim:imageview

并设置“[nav.navigationBar.topItem setTitle:@您想要的文本]

[nav.navigationBar.topItem setTitleView:imageView];

感谢您的回复,但它给了我一个错误,因为无法将字符串分配给SetTitleWits not TitleWith it’s just title您可以看到更新的标题。如果您接受答案,则接受为正确答案否亲爱的,它还没有显示标题,只是在Center上显示图像是滑动视图控制器吗?为什么不能尝试自定义栏按钮,将customview设置为imageview,并将其设置为navigationbar.leftbarbuttonitem设置为该自定义栏发送任何一个设计示例抱歉,我无法回答您的问题。你能详细描述一下你正在做的事情和你的期望吗
UIImage* image3 = [UIImage imageNamed:@"mail-48_24.png"];
CGRect frameimg = CGRectMake(0, 0, image3.size.width, image3.size.height);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:image3 forState:UIControlStateNormal];
[someButton addTarget:self action:@selector(sendmail)
     forControlEvents:UIControlEventTouchUpInside];
[someButton setShowsTouchWhenHighlighted:YES];

UIBarButtonItem *mailbutton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.leftBarButtonItem=mailbutton;
[someButton release];