How to show a title on navigationBar from database - ios

Really thank you all for the answers in my first question.
Now i like to do something easy i think, but im trying to do it for some days and i finally i cant.
I continued using the same project of my first question
www.raywenderlich.com/913/sqlite-101-for-iphone-developers-making-our-app
See this image please.
http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2010/04/FailedBanksTableView.jpg
Here we see "Failed Banks" on the navigationBar in the ListView. I know how to change that title, but i like to show the name of the bank on the navigationBar in DetailView.
See this image. For example, i like to show "McIntosh Commercial Bank" on the navigationBar.
http://d1xzuxjlafny7l.cloudfront.net/wp-content/uploads/2010/04/DetailView.jpg
I think this is not complicated, but i cant solve it yet.
Maybe can you explain me how to do it or show me how the code have to be.
Thank you for your time.

just do the following in "viewDidLoad" (or place it there where you've got the title from your database):
self.title = #"McIntosh Commercial Bank";

Since your DetailView controller is being managed by a UINavigationController, you need to set the title property of your DetailView's UINavigationItem in order for it to show in the top navbar, like this:
- (void)viewDidLoad
{
[super viewDidLoad];
self.navigationItem.title = #"McIntosh Commercial Bank";
}

Related

Adding a button at the bottom of JSQMessagesCollectionView

I am newbie in iOS. Sorry for my English. Actually I want a button at the bottom of my JSQMessagesCollectionViewenter image description here. I have tried to put it like "drag" and "drop". But it doesn't work there. I know there must be a silly mistake which I am doing with the logic. But I need someone's help to guide me the correct way to do it. Thanks in advance. :)
JSQMessagesCollectionViewController was deprecated I would suggest you to replace it with something else as soon as you can. MessageKit for example.
THis is out side the scope of the JSQ library. I guess it could be in the scope of the library depending on what the button does but JSQ really only helps when it comes to chat. So if the CollectionView you have displayed is the chat part of your app you could add a button in the inputBar but the screen shot does not seem to indicate that. Other wise what you are doing should be pretty strait forward. You could add a button via StoryBoard add Constraints to pin it to the bottom of your screen and hook up the outlets for it to do the action you desire. Or you could do it programmatically in your ViewController. That is about all the help that can be provided with the information given. If share more of you code we may be able to provide more guidance.
Daniel is saying right this is out of the scope of the jsq library still if you want to add Button or other view i will suggest you to add it programmatically to your JSQMessagesViewController SubClass like if i am understanding your question you can add view above the JSQMessagesViewController's Subclass's inputToolBar as -
UIView *v = [[UIView alloc]initWithFrame:CGRectMake(0, self.inputToolbar.frame.origin.y - self.inputToolbar.frame.size.height, self.view.frame.size.width, 55)];
v.backgroundColor = [UIColor redColor];
[self.view addSubview:v];
now then you have to change the position of view / button each time keyboard appear or disappear as inputbar becomes first responder. As far as i am understanding your question i think this will help.
Although You can also change the XIB of InputToolBar and Can customize your Button in storyboard(xib) then do changes in the class of InputToolBar according to your needs.

Add "Sub" view in navigation controller xcode

Good day StackOverflow Community! I have come with the following question: How can I add this sub view, that displays the date of posts someone is currently viewing, into my basic navigation controller? The view is a UITableView. See picture link below what I mean. What I mean can be seen in the red box. You see "Vandaag" this means Today in Dutch. And that is basically what I want, to add a subview into my navigation controller that displays the date of the posts. The coding language I use is Swift.
https://ibb.co/gsLJsv
Now I have to tell you, when it comes to XCode I am greener then a nauseous Hulk. So if it is not clear what I mean, then feel free to point out.
You can use this code:
self.navigationItem.title = #"TODAY";
Or if you want yo have more customizable way, you could use this:
let labelTitle = UILabel(frame:CGRect.zero)
labelTitle.text = "Today"
labelTitle.text.textAlignment = NSTextAlignment.center
navigationItem.titleView = labelTitle

implementing textViewDidChange:

So, I have this very simple list project with objective-c, where every item on the list should have a title and a description. When clicking on one of the items, the detail view of the item shows up. The title, on the navigation bar is the item's title, and the rest of the view is the item's description. By clicking on the title, the user should be able to change it, and by clicking on the description they should also be able to change it.
Up until changing the title everything is going OK, I've managed to do that. The problem is when it comes to changing the description. I tried using the delegate, but I guess I must be using some command wrong, because it's simply not working. I tried looking for it online, but all I find are solutions for the TextField, which doesn't really help me, since I want to display a possibly multiline description, and I would rather not have to change from a TextView to a TextField every time the user wants to edit it. So if anyone could help me out with that, that would be awesome.
Here is the code where I try using the delegate.
on viewDidLoad I have this:
[self.descriptionLabel setDelegate:self.descriptionLabel.delegate];
and then I have this, where it should perform the actions after the text is changed:
- (void)textViewDidChange:(UITextView *)textView {
NSLog(#"Hello World");
}
P.S.: I was also looking for a way to have the "Done" button show up over the keyboard, because as of now, once the keyboard is brought up, the only way to get it down again is going back to the table view and then into the detail view again. I tried a couple of things already, but I'll admit that I wasn't too thorough on my research. So, as a side note, if you could show that too, it would be great, otherwise, the one thing I'm really after here is the question above. Thanks for any help! :]
Summary of answer based on the comments.
The line:
[self.descriptionLabel setDelegate:self.descriptionLabel.delegate];
needs to be:
self.descriptionLabel.delegate = self;
You want the view controller to be the delegate since the view controller implements the text view delegate methods.
You also need to indicate that the view controller conforms to the UITextViewDelegate protocol.
In your .m file, add the following:
#interface DetailViewController () <UITextViewDelegate>
#end

Custom UIBarButtonItem/UISegmentedControl for UINavigationController

Currently I would like to make my UINavigationController have the look and feel like facebook's main view.
I was thinking about using a UIsegmentedControl which would have a transparent background with an image inputted into the button's view.
Another idea was creating custom buttons with their background image as an image.
If anyone has any ideas on how this is done or an example project I can refer to, please REFER me!!! Haha.
Thank you stackoverflow!!!
in this case i would just use standard UIBarButtonItems for the left and right ones.
The center would then be a custom view with 3 buttons inside.
UINavigationItem has a property called 'titleView'.
So in some appropriate controller just do s.th. like:
self.navigationItem.titleView = myCustomViewWithThreeButtonsAsSubviews;
self.navigationItem.rightBarButtonItem = myLeftUIBarButtonItem;
self.navigationItem.leftBarButtonItem = myRightUIBarButtonItem;
setting the styles of the barButtontem to UIBarButtonItemStylePlain and providing images will do the job easily.

iOS Can't change UIBarButtonItem image properly

I'm having a problem when I try to change a UINavigationBar's "back" button custom icon. To achieve such a thing, I'm using the following code:
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem* leftBtn;
UIImage* botonVolverImg = [UIImage imageNamed:#"boton_volver.png"];
leftBtn = self.navigationItem.leftBarButtonItem;
leftBtn.image = botonVolverImg;
}
But, when the view appears, you see this:
a busy cat http://www.timotteo.com.ar/boton.png
(You can see that the old button still appears at the back, plus the image I chose looks a bit streched)
I've been changing the imageInsets property, but that doesn't seem to work. I've also been reading the forum around, but couldnĀ“t find the exact solution.
Any suggestions are welcomed!
The image property for UIBarButtonItem doesn't correspond to the background image, only an image that provides additional context. If you're targeting 5.0+, your best bet would be to use -setBackButtonBackgroundImage:forState:barMetrics: to set a background for the bar button item.
To supplement Mark's answer, if your customer is requiring you to support iOS 4, you could create a UIButton that looks exactly how your customer wants it to (ie, just that image), and then use UIBarButton's initWithCustomView method to create your own back button. You can then have that button trigger popViewController or whatever appropriate action you need.

Resources