MKAnnotation "title" property, how to suppress when using left/rightCalloutAccessoryView? - iphone

The situation in iOS 5 appears to be that a callout will not be displayed for a MKAnnotationView when the id's title is nil. MKAnnotationView Class Reference:
(If the annotation’s title method returns an empty string, the
annotation view is treated as if its enabled property is set to NO.)
What I want to do is display a callout entirely composed of views, no NSStrings. There will be a string on my leftCalloutAccessoryView but moving it to title is going to mess up the design. For one thing it is not in the system font but must match the rest of the app.
Can a MKAnnotationView be made to pop up a callout composed entirely of the views returned by leftCalloutAccessoryView and rightCalloutAccessoryView, with no title between?

try this:-
annotation.title=#" ";
don't set the title string to empty, set one space character in string, in this way the no string will be shown in title and your callout will be displayed properly.

Related

Edit Name of cell upon tap - Swift

I want to edit the text in a cell by tapping and I was wondering if there is a way to do it other than by adding a text field. is there something in the table view delegate that I missed?
You can create cell (or any other UIResponder subclass) that conforms UITextInput protocol (or maybe UIKeyInput is enough). Here is simple example (old link)
Notice,
you should set cell.canBecomeFirstResponder = true.
To show keyboard use cell.becomeFirstResponder()
Maybe there something else, that you should do. I recommend reading docs.
...Or use UITextField :)
We use an array to display no of text label in cell.
so you can do is, you can use a text field and a button on a view.
In button action add a line of code like stringArray[2] = "new string" to replace the particular element from array and when you enter a text and press a button the element will get replaced and just reload the table view.
And you can also write the method in didSelectRowAtIndexPath, write stringArray[indexPath.row] = "new string" and reload the table view and it is done.

multiple annotation have issue to get selected index annotation

I have displayed multiple annotation successfully in mapView in my iphone application, but I have problem too .. In top of the screen I have two Tab Map and List . map display all annotation in map and list display those data in Tableview which is display in map. when I click on particular cell i get all the particular detail of that cell.but when I try to get id from Tap annotation my array getting lots of id after comparison of name because we have same name in my array list so how can I differentiate from annotation tag. How to set tag of annotations ?
In the calloutAccessoryControlTapped delegate method, use view.annotation to access the annotation that was tapped.
If you have a custom annotation class, you can cast it to easily access the properties (you may also want to first check if the annotation tapped is an instance of the class you're interested in--important if you're using multiple annotation classes):
if ([view.annotation isKindOfClass:[TagMark class]]) {
TagMark *tm = (TagMark *)view.annotation;
NSLog(#"tm.someProperty = %#", tm.someProperty);
}

How i can fetch what is typed between 2 UITextViews on iphone?

i have two UITextView items, how can i fetch what is written using a button on iphone?
Imagine something like a translate app, the user enters a word in UITextView 1 and by pressing the button the UITextView 2 is getting filled with data.
UITextView has a property text. Simply use this.
Set up IBOutlets for textView1 and textView2. Then have the button do something along these lines:
-(IBAction)moveTextOver:(id)sender {
[textView2 setText:textView1.text];
}
To get fancier, you can have a method -(NSString *)transformText:(NSString *)text that translates or does whatever you like. Then use
-(IBAction)moveTextOver:(id)sender {
[textView2 setText:[self transformText:textView1.text]];
}
Create an IBAction method that is linked to a button and in that method read the "text" property of the textView or textField, do your calculations on it and assign the results to the text property of thee second field.

Space between labels when user leave a text field empty

Hi
I have some text field which, after a decoding, set some UILabel. The problem is that if the user leave some empty field , I don't like to see that space between the labels. I enclose a picture for a better understanding. thanks in advance.
instead of the view below use a uitableview with custom cells
Each custom cell having a label ...and add a cell if and only if u have a valid string in a textfeild..set userinteraction=NO and set some backgroung color to match ur view..
just put that string in the uilabel in the custom cell...thats it..

How to word wrap text in annotation subtitle

I tried to insert return and newline chars into the subtitle string, but they ended up as "spaces" and not line breaks. Since subtitle is simply an NSString I must look at the container, which likely means I'll have to roll my own annotation views.
The NSString do become f.ex. "90510\nHollywood, CA", but maybe I have to 'encode' the newlines instead, or use a subclass of NSString to send to subtitle?
What baffles me is that surely, subtitle should be able to "be wrappable", as the MKAnnotation(view) handles too long text by resizing the bubble and adding "...", et cetera.
I do need proper word wrap (and not hard line breaks) for a paragraph of text I'm adding later, but I could possibly do that as a separate alert or modal box type, if you know which ones support word wrap I'd be grateful if you could suggest them.
A hunch is that something could be possible by adding a UILabel as a subview, or somehow access the UILabel(?) that is used to display the subtitle, and set its numberOfLines to 0, but I don't know how to do the latter.
AFAIK it can't be done. Setting left/right button text is space-limited indeed. Seems the only solution is to addObserver and roll your own animated views entirely.