2013-08-30 145 views
0
- (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; 
} 

我曾嘗試在AppDelegate類的代碼,因爲我希望它在整個項目中,它的工作原理用於顯示圖像,但它顯示了在中心還我需要的文字,其我無法顯示。在左側導航欄上添加圖像和文字一起

請可能有人建議我如何能在iOS的

+0

發送任何一個設計示例 – Deepesh

+0

對不起,我無法得到您的問題。可以詳細說明請 – Funny

+0

添加圖像或屏幕截圖,你正在做什麼,你期待什麼 – NHS

回答

-1

同時顯示圖像和文字上的導航欄的左側爲什麼要設置imageview的導航topItem titleview的

更換

[nav.navigationBar.topItem setTitleView:imageView]; 

nav.navigationbar.topItem.leftBarButtonItem:imageview

並設置了[[nav.naviga tionBar.topItem setTitle:@「你想要的文字」];

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]; 
+0

感謝您的答覆,但它給了我一個錯誤,因爲不能指定字符串setTitleView – Funny

+0

它不是titleview它只是標題,你可以看到更新的。如果你接受答案,然後接受作爲正確的答案 – NHS

+0

沒有親愛的,它不顯示標題,只顯示中心的圖像 – Funny