我有一個簡單的應用程序,將允許用戶標記的位置。應用程序1中的2個按鈕用於清除標記,1用於標記位置。用的UITextField添加用戶文字輸入地圖標註
我有工作UIAlertView中嵌入。我需要從UITextfield獲取用戶輸入並將其應用於地圖上的註釋。我的標籤按鈕代碼是
- (void) tag
{
MapAnnotation *annotation = [[MapAnnotation alloc] initWithCoordinate:current.coordinate];
NSString *locString = [NSString stringWithFormat:@"%f, %f", current.coordinate.latitude, current.coordinate.longitude];
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
formatter.timeStyle = NSDateFormatterLongStyle;
//insert UITextfield
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Name your Location" message:nil delegate:self cancelButtonTitle:@"Continue" otherButtonTitles: nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * alertTextField = [alert textFieldAtIndex:0];
alertTextField.keyboardType = UIKeyboardTypeDefault;
alertTextField.placeholder = @"Enter title of your tag";
[alert show];
// I have tried numerous variations of NSString below
//NSString *pintitle = NSLog(@"%@", alertTextField.text);
annotation.title = pintitle;
annotation.subtitle = locString;
[mapView addAnnotation:annotation];
}
我已經嘗試了幾個選項,一些返回空值和其他什麼都沒有。我開始iOS開發,只是不能讓這部分想出
我不得不承認,我是一個完整的noob,並通過一些代碼,我已經從GitHub編輯去。我將如何保留新的或編輯過的註釋的參考? – matt 2012-04-02 18:03:49
只需聲明該類的屬性。這是一個很平常的事... – Mundi 2012-04-02 23:32:07
終於得到了它的工作,感謝您的幫助 – matt 2012-04-04 15:39:45