NavigationController NavigationBar TitleView is Not Working in Navigation Bar Large Title in iOS Objective-C












0















I'm stuck in titleview When i used Navigationitem.title then it show me in large title but title view is does not show please guys help me for this Thank You
enter image description here



:- searchBar Configure Code :-
self.searchControllerInvoice = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchControllerInvoice.searchResultsUpdater = self;
self.searchControllerInvoice.delegate = self;

:- Navigation And TitleBUtton :-
CGFloat maxTitleWidth = self.navigationController.navigationBar.frame.size.width;
CGSize requestedTitleSize = [selectedName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17]}];
CGFloat titleWidth = MIN(maxTitleWidth-130, requestedTitleSize.width);

if(!TitleButton)
{
TitleButton = [UIButton buttonWithType:UIButtonTypeSystem];
[TitleButton setFrame:CGRectMake(0, 0, titleWidth , 22)];
}

[TitleButton.titleLabel setFont:[UIFont systemFontOfSize:17]];

TitleButton.titleLabel.adjustsFontSizeToFitWidth = YES;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[TitleButton setTitle:selectedName forState:UIControlStateNormal];
[TitleButton setImage:image forState:UIControlStateNormal];
[TitleButton addTarget:self action:@selector(titleButtonClicked:) forControlEvents:UIControlEventTouchUpInside];

TitleButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

if (@available(iOS 11.0, *)) {
self.navigationItem.searchController = self.searchControllerInvoice;
// [self.navigationItem.searchController.searchBar setBackgroundColor:UIColor.redColor];
} else {
self.getInvoiceTable.tableHeaderView = self.searchControllerInvoice.searchBar;
}

self.navigationItem.titleView=TitleButton;









share|improve this question

























  • Where is your code!!!?

    – Ankur Lahiry
    Jan 1 at 12:42











  • Please check i have just added code

    – Yogesh Patel
    Jan 1 at 12:45











  • Please add code of search bar that how it configure.

    – Sagar Chauhan
    Jan 2 at 4:44











  • Please check i have update code for searchbar too.

    – Yogesh Patel
    Jan 2 at 4:48
















0















I'm stuck in titleview When i used Navigationitem.title then it show me in large title but title view is does not show please guys help me for this Thank You
enter image description here



:- searchBar Configure Code :-
self.searchControllerInvoice = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchControllerInvoice.searchResultsUpdater = self;
self.searchControllerInvoice.delegate = self;

:- Navigation And TitleBUtton :-
CGFloat maxTitleWidth = self.navigationController.navigationBar.frame.size.width;
CGSize requestedTitleSize = [selectedName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17]}];
CGFloat titleWidth = MIN(maxTitleWidth-130, requestedTitleSize.width);

if(!TitleButton)
{
TitleButton = [UIButton buttonWithType:UIButtonTypeSystem];
[TitleButton setFrame:CGRectMake(0, 0, titleWidth , 22)];
}

[TitleButton.titleLabel setFont:[UIFont systemFontOfSize:17]];

TitleButton.titleLabel.adjustsFontSizeToFitWidth = YES;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[TitleButton setTitle:selectedName forState:UIControlStateNormal];
[TitleButton setImage:image forState:UIControlStateNormal];
[TitleButton addTarget:self action:@selector(titleButtonClicked:) forControlEvents:UIControlEventTouchUpInside];

TitleButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

if (@available(iOS 11.0, *)) {
self.navigationItem.searchController = self.searchControllerInvoice;
// [self.navigationItem.searchController.searchBar setBackgroundColor:UIColor.redColor];
} else {
self.getInvoiceTable.tableHeaderView = self.searchControllerInvoice.searchBar;
}

self.navigationItem.titleView=TitleButton;









share|improve this question

























  • Where is your code!!!?

    – Ankur Lahiry
    Jan 1 at 12:42











  • Please check i have just added code

    – Yogesh Patel
    Jan 1 at 12:45











  • Please add code of search bar that how it configure.

    – Sagar Chauhan
    Jan 2 at 4:44











  • Please check i have update code for searchbar too.

    – Yogesh Patel
    Jan 2 at 4:48














0












0








0








I'm stuck in titleview When i used Navigationitem.title then it show me in large title but title view is does not show please guys help me for this Thank You
enter image description here



:- searchBar Configure Code :-
self.searchControllerInvoice = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchControllerInvoice.searchResultsUpdater = self;
self.searchControllerInvoice.delegate = self;

:- Navigation And TitleBUtton :-
CGFloat maxTitleWidth = self.navigationController.navigationBar.frame.size.width;
CGSize requestedTitleSize = [selectedName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17]}];
CGFloat titleWidth = MIN(maxTitleWidth-130, requestedTitleSize.width);

if(!TitleButton)
{
TitleButton = [UIButton buttonWithType:UIButtonTypeSystem];
[TitleButton setFrame:CGRectMake(0, 0, titleWidth , 22)];
}

[TitleButton.titleLabel setFont:[UIFont systemFontOfSize:17]];

TitleButton.titleLabel.adjustsFontSizeToFitWidth = YES;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[TitleButton setTitle:selectedName forState:UIControlStateNormal];
[TitleButton setImage:image forState:UIControlStateNormal];
[TitleButton addTarget:self action:@selector(titleButtonClicked:) forControlEvents:UIControlEventTouchUpInside];

TitleButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

if (@available(iOS 11.0, *)) {
self.navigationItem.searchController = self.searchControllerInvoice;
// [self.navigationItem.searchController.searchBar setBackgroundColor:UIColor.redColor];
} else {
self.getInvoiceTable.tableHeaderView = self.searchControllerInvoice.searchBar;
}

self.navigationItem.titleView=TitleButton;









share|improve this question
















I'm stuck in titleview When i used Navigationitem.title then it show me in large title but title view is does not show please guys help me for this Thank You
enter image description here



:- searchBar Configure Code :-
self.searchControllerInvoice = [[UISearchController alloc] initWithSearchResultsController:nil];
self.searchControllerInvoice.searchResultsUpdater = self;
self.searchControllerInvoice.delegate = self;

:- Navigation And TitleBUtton :-
CGFloat maxTitleWidth = self.navigationController.navigationBar.frame.size.width;
CGSize requestedTitleSize = [selectedName sizeWithAttributes:@{NSFontAttributeName: [UIFont systemFontOfSize:17]}];
CGFloat titleWidth = MIN(maxTitleWidth-130, requestedTitleSize.width);

if(!TitleButton)
{
TitleButton = [UIButton buttonWithType:UIButtonTypeSystem];
[TitleButton setFrame:CGRectMake(0, 0, titleWidth , 22)];
}

[TitleButton.titleLabel setFont:[UIFont systemFontOfSize:17]];

TitleButton.titleLabel.adjustsFontSizeToFitWidth = YES;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
[TitleButton setTitle:selectedName forState:UIControlStateNormal];
[TitleButton setImage:image forState:UIControlStateNormal];
[TitleButton addTarget:self action:@selector(titleButtonClicked:) forControlEvents:UIControlEventTouchUpInside];

TitleButton.semanticContentAttribute = UISemanticContentAttributeForceRightToLeft;
TitleButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;

if (@available(iOS 11.0, *)) {
self.navigationItem.searchController = self.searchControllerInvoice;
// [self.navigationItem.searchController.searchBar setBackgroundColor:UIColor.redColor];
} else {
self.getInvoiceTable.tableHeaderView = self.searchControllerInvoice.searchBar;
}

self.navigationItem.titleView=TitleButton;






ios objective-c uinavigationcontroller uinavigationbar






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 2 at 4:47







Yogesh Patel

















asked Jan 1 at 8:39









Yogesh PatelYogesh Patel

9029




9029













  • Where is your code!!!?

    – Ankur Lahiry
    Jan 1 at 12:42











  • Please check i have just added code

    – Yogesh Patel
    Jan 1 at 12:45











  • Please add code of search bar that how it configure.

    – Sagar Chauhan
    Jan 2 at 4:44











  • Please check i have update code for searchbar too.

    – Yogesh Patel
    Jan 2 at 4:48



















  • Where is your code!!!?

    – Ankur Lahiry
    Jan 1 at 12:42











  • Please check i have just added code

    – Yogesh Patel
    Jan 1 at 12:45











  • Please add code of search bar that how it configure.

    – Sagar Chauhan
    Jan 2 at 4:44











  • Please check i have update code for searchbar too.

    – Yogesh Patel
    Jan 2 at 4:48

















Where is your code!!!?

– Ankur Lahiry
Jan 1 at 12:42





Where is your code!!!?

– Ankur Lahiry
Jan 1 at 12:42













Please check i have just added code

– Yogesh Patel
Jan 1 at 12:45





Please check i have just added code

– Yogesh Patel
Jan 1 at 12:45













Please add code of search bar that how it configure.

– Sagar Chauhan
Jan 2 at 4:44





Please add code of search bar that how it configure.

– Sagar Chauhan
Jan 2 at 4:44













Please check i have update code for searchbar too.

– Yogesh Patel
Jan 2 at 4:48





Please check i have update code for searchbar too.

– Yogesh Patel
Jan 2 at 4:48












2 Answers
2






active

oldest

votes


















0














First of all you are using button in large title, about that I've no idea.



But, when you use default title for large title, you need to enable following properties in AppDelegate's method:



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

[[UINavigationBar appearance] setPrefersLargeTitles:true];

return YES;
}


Output:



Large Title



This will enable large title for you all screen in default navigation bar.



I hope this will help you.






share|improve this answer
























  • Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

    – Yogesh Patel
    Jan 1 at 13:22



















0














The iOS large title does not work with custom title views as you want.



If a navigationItem has both it's title and titleView properties set and the navigationBar has prefersLargeTitles set to YES you will get both a large title displayed in a second line while the provided titleView is show as usual at the top center of the navigation bar.



Long story short: this is not possible.






share|improve this answer
























  • Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

    – Yogesh Patel
    Jan 1 at 17:39













  • Not that I know of.

    – D. Mika
    Jan 1 at 17:40











  • Okay ThAnk You so much for your time :-)

    – Yogesh Patel
    Jan 1 at 17:42











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994095%2fnavigationcontroller-navigationbar-titleview-is-not-working-in-navigation-bar-la%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














First of all you are using button in large title, about that I've no idea.



But, when you use default title for large title, you need to enable following properties in AppDelegate's method:



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

[[UINavigationBar appearance] setPrefersLargeTitles:true];

return YES;
}


Output:



Large Title



This will enable large title for you all screen in default navigation bar.



I hope this will help you.






share|improve this answer
























  • Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

    – Yogesh Patel
    Jan 1 at 13:22
















0














First of all you are using button in large title, about that I've no idea.



But, when you use default title for large title, you need to enable following properties in AppDelegate's method:



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

[[UINavigationBar appearance] setPrefersLargeTitles:true];

return YES;
}


Output:



Large Title



This will enable large title for you all screen in default navigation bar.



I hope this will help you.






share|improve this answer
























  • Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

    – Yogesh Patel
    Jan 1 at 13:22














0












0








0







First of all you are using button in large title, about that I've no idea.



But, when you use default title for large title, you need to enable following properties in AppDelegate's method:



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

[[UINavigationBar appearance] setPrefersLargeTitles:true];

return YES;
}


Output:



Large Title



This will enable large title for you all screen in default navigation bar.



I hope this will help you.






share|improve this answer













First of all you are using button in large title, about that I've no idea.



But, when you use default title for large title, you need to enable following properties in AppDelegate's method:



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

[[UINavigationBar appearance] setPrefersLargeTitles:true];

return YES;
}


Output:



Large Title



This will enable large title for you all screen in default navigation bar.



I hope this will help you.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 1 at 13:14









Sagar ChauhanSagar Chauhan

2,0081621




2,0081621













  • Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

    – Yogesh Patel
    Jan 1 at 13:22



















  • Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

    – Yogesh Patel
    Jan 1 at 13:22

















Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

– Yogesh Patel
Jan 1 at 13:22





Hii, this allow large title but i don't want to large my title i want to large my titleview button Thanks For Your Answer

– Yogesh Patel
Jan 1 at 13:22













0














The iOS large title does not work with custom title views as you want.



If a navigationItem has both it's title and titleView properties set and the navigationBar has prefersLargeTitles set to YES you will get both a large title displayed in a second line while the provided titleView is show as usual at the top center of the navigation bar.



Long story short: this is not possible.






share|improve this answer
























  • Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

    – Yogesh Patel
    Jan 1 at 17:39













  • Not that I know of.

    – D. Mika
    Jan 1 at 17:40











  • Okay ThAnk You so much for your time :-)

    – Yogesh Patel
    Jan 1 at 17:42
















0














The iOS large title does not work with custom title views as you want.



If a navigationItem has both it's title and titleView properties set and the navigationBar has prefersLargeTitles set to YES you will get both a large title displayed in a second line while the provided titleView is show as usual at the top center of the navigation bar.



Long story short: this is not possible.






share|improve this answer
























  • Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

    – Yogesh Patel
    Jan 1 at 17:39













  • Not that I know of.

    – D. Mika
    Jan 1 at 17:40











  • Okay ThAnk You so much for your time :-)

    – Yogesh Patel
    Jan 1 at 17:42














0












0








0







The iOS large title does not work with custom title views as you want.



If a navigationItem has both it's title and titleView properties set and the navigationBar has prefersLargeTitles set to YES you will get both a large title displayed in a second line while the provided titleView is show as usual at the top center of the navigation bar.



Long story short: this is not possible.






share|improve this answer













The iOS large title does not work with custom title views as you want.



If a navigationItem has both it's title and titleView properties set and the navigationBar has prefersLargeTitles set to YES you will get both a large title displayed in a second line while the provided titleView is show as usual at the top center of the navigation bar.



Long story short: this is not possible.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 1 at 17:30









D. MikaD. Mika

966413




966413













  • Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

    – Yogesh Patel
    Jan 1 at 17:39













  • Not that I know of.

    – D. Mika
    Jan 1 at 17:40











  • Okay ThAnk You so much for your time :-)

    – Yogesh Patel
    Jan 1 at 17:42



















  • Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

    – Yogesh Patel
    Jan 1 at 17:39













  • Not that I know of.

    – D. Mika
    Jan 1 at 17:40











  • Okay ThAnk You so much for your time :-)

    – Yogesh Patel
    Jan 1 at 17:42

















Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

– Yogesh Patel
Jan 1 at 17:39







Hii, can i do this thing using any custom library or that titlebutton Y position set to minus it anything that helps me .?

– Yogesh Patel
Jan 1 at 17:39















Not that I know of.

– D. Mika
Jan 1 at 17:40





Not that I know of.

– D. Mika
Jan 1 at 17:40













Okay ThAnk You so much for your time :-)

– Yogesh Patel
Jan 1 at 17:42





Okay ThAnk You so much for your time :-)

– Yogesh Patel
Jan 1 at 17:42


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53994095%2fnavigationcontroller-navigationbar-titleview-is-not-working-in-navigation-bar-la%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Mossoró

Error while reading .h5 file using the rhdf5 package in R

Pushsharp Apns notification error: 'InvalidToken'