MKMap annotation selection - ios4

I want to check when he user presses the annotation (the bubble on top of the pin). I tried the following :
-(void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view{}
but it fires up when i press the pin. How can i check when the user actually presses on the annotation bubble?

You can first put a right accessory button and set an separate action for it as such:
UIButton* rightButton = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
[rightButton addTarget:self
action:#selector(showDetails:)
forControlEvents:UIControlEventTouchUpInside];
customPinView.rightCalloutAccessoryView = rightButton;
you can implement the showDetails method with the function that you like

Related

How to hide shortcut bar in iOS9 UIWebview?

I would like to hide bar which is on top of keyboard (undo, redo, copy and back, forward buttons) when user clicks on textfield in UIWebView.
Does anybody know how to do it?
Thanks!
Using method swiziling we can remove the keyboard shortcut bar (only works with ObjC).
- (void)hideKeyboardShortcutBar
{
Class webBrowserClass = NSClassFromString(#"UIWebBrowserView");
Method method = class_getInstanceMethod(webBrowserClass, #selector(inputAccessoryView));
IMP newImp = imp_implementationWithBlock(^(id _s) {
if ([self.webView respondsToSelector:#selector(inputAssistantItem)]) {
UITextInputAssistantItem *inputAssistantItem = [self.webView inputAssistantItem];
inputAssistantItem.leadingBarButtonGroups = #[];
inputAssistantItem.trailingBarButtonGroups = #[];
}
return nil;
});
method_setImplementation(method, newImp);
}
inputAccessoryView
: This property is typically used to attach an accessory view to the
system-supplied keyboard that is presented for UITextField and
UITextView objects.
So the new implementation block will be fired every time the keyboard pops up.
I posted this answer in Hide shortcut keyboard bar for UIWebView in iOS 9 as well
I am able to hide those using these lines
let item:UITextInputAssistantItem = self.textFieldName.inputAssistantItem
item.leadingBarButtonGroups = []
item.trailingBarButtonGroups = []
Hope this will help.

TabBar Segue when selecting row in table view controller

I already have a segue set in place in my table view controller for an add button press. Now I want to have another segue for when the user selects on the newly added object. My code looks like this so far:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:#"Add Vehicle Segue"])
{
NSLog(#"Setting RootViewController as a delegate of AddViewController");
AddViewController *addViewController = segue.destinationViewController;
addViewController.delegate = self;
addViewController.managedObjectContext = self.managedObjectContext;
}
I think I will need to add an else if next to take care of the tab bar segue but don't know how to do that.
Also the tab bar view is just there to show the two tabs so I don't believe I will preform the segue with the reference to core data.
Thanks in advance.!
My storyboard flow
If you do not want to pass value to the next view controller or do any actions that need to done before performing the segue, but just display the tab bar then you don't need to add anything in the prepareForSegue:sender: method. If you do have to do something when performing the segue add and else condition as there is only two segues and write your code inside the else block.

Click OK in Dialog box display output text in SDI

I have a dialog box displayed when I press a menu item in the SDI window. In the Dialog box When i press OK button it should display "SUCESS" in the SDI window... In ONVIEW() i have to use pDC->TEXTOUT() but how to execute that statement on pressing OK button.. I am using visual C++ 6
you should define a user defined message and use PostMessage to call your method in SDI Window.
I am working on assumption that your dialog is modal.
You do not have to define or send any messages.
Retrieve data from the dialog.
Presumably you store 2D vector data in some kind of an array declared as a member variable of the dialog.
When OK button is pushed and copy data to a view’s member variable of the same type. Use it to draw whatever you desire.
void CSDIPopupSampleView::OnViewDialog()
{
CSimpleDlg dlg;
int iResponse = dlg.DoModal();
if(IDOK == iResponse)
{
//Copy data from a dialog here.
}
Invalidate(); // this will cause redraw
}

LWUIT - show TextField blinking Cursor, even if the field is empty

I have a TextField in a Form. This TextField should have focus by default,
which works fine. Now I'd like the user to be aware of that and show him,
that he's inside the TextField - so the TextField cursor should be shown
and blink.
I only found drawTextFieldCursor in DefaultLookAndFeel. but I have
absolutely no idea how to apply this to my TextField.
Any help - and code would be appreciated!
Here's a sample. I still don't have it working.
public void search2() {
searchForm = new Form();
TextField searchArea = new TextField();
searchForm.setLayout(new BoxLayout(BoxLayout.Y_AXIS));
searchForm.addComponent(searchArea);
searchArea.requestFocus();
int i = Display.getInstance().getKeyCode(Display.GAME_FIRE);
searchArea.keyPressed(i);
searchArea.keyReleased(i);
searchForm.show();
}
What happens is: the TextField is focused, it can be directly edited, the "Abc" mode is shown, but what I really want is to show the user the cursor, so he KNOWS he's inside the TextField. This is not happening... if someone could show me some working code for that...
You want the text field to be in editing mode not for the text field cursor to show (which happens when editing). Use requestFocus() to make sure the text field has focus then use something like:
int i = Display.getInstance().getKeyCode(Display.GAME_FIRE);
tf.keyPressed(i);
tf.keyReleased(i);
The drawTextFieldCursor method has a Graphics parameter , so the way you can draw your cursor is :
derive TextField
in its public void paint(Graphics g) you call drawTextFieldCursor after setting the drawing methods of the TextField's paint Graphic.

Problem in Handling the Mouse click of CListCtrl

I have a listctrl with CheckBox in it(LVS_EX_CHECKBOXES) .It is a single column List Control . My Problem is when I Click on the CheckBox the particular item is getting selected/UnSelected. But when I click on the Item text the corresponding Checkbox is not getting Selected/UnSelected . How to handle both the Scenarios.
To check the item when the user clicks on the item text, you'll have to handle the NM_CLICK message, which is sent whenever the user clicks on the item.
Something along the lines of:
CYourListCtrl::OnNMClick(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
int nItemIndex = pNMItemActivate->iItem;
BOOL bCurrentCheckState = GetCheck(nItemIndex);
SetCheck(nItemIndex, !bCurrentCheckState);
*pResult = 0;
}
I'm writing this without testing though, so you'll have to make sure that it doesn't conflict with the handler for clicks on the check box iteself.

Resources