大家好,
我使用 LocationManager,Geocoder和Placemark 来获取用户的地址。一切正常。
启动standardUpdates后,我使用以下函数:
[...]
-(void)locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray *)locations {
CLLocation* location = [locations lastObject];
[self.geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error) {
if (error == nil && [placemarks count] > 0) {
self.placemark = [placemarks lastObject];
NSString *placemarkCountry = self.placemark.country;
NSString *placemarkPostalCode = self.placemark.postalCode;
NSString *placemarkAdministrativeArea = self.placemark.administrativeArea;
NSString *placemarkLocality = self.placemark.locality;
NSString *placemarkThoroughfare = self.placemark.thoroughfare;
NSString *placemarkSubThoroughfare = self.placemark.subThoroughfare;
[...] //here I'm displaying the address, nothing special
}
现在我想使用 ABUnknownPersonViewController 和 AddressBookUI 将地址添加到新的或现有的联系人。
-(IBAction)addAddressToContactButtonPressed {
[...]
}
下图显示了它应该是什么样的:
问题: 函数 addAddressToContactButtonPressed 应该如何?你能帮帮我吗?该函数应使用NSStrings placemarkCountry,placemarkPostalCode,...并打开带有这些信息的ABUnknownPersonViewController。用户应使用此地址创建新联系人,或将此地址添加到现有用户。
我找了一些教程,但找不到任何有用的(对我有用)帮助。我是一个通过寻找教程学习的人,现在我被卡住了。
Thank you for your help and your answers.
:-)
答案 0 :(得分:1)
制作一个ABUnknownPersonViewController。给它一个代表。
创建一个ABPerson。为ABPerson(ABRecord)分配您希望它拥有的任何功能:在本例中为地址。
将ABPerson设为ABUnknownPersonViewController' s Dim startDate As DateTime
Dim endDate As DateTime
If Not DateTime.TryParse(TextBox2.Text, startDate) Then
' there was an error parsing - do something useful
startDate = New DateTime(2000, 1, 1)
End If
If Not DateTime.TryParse(TextBox3.Text, endDate) Then
' there was an error parsing - do something useful
endDate = New DateTime(2100, 12, 31)
Else
' add a day to include it in the range selected in the SQL query
endDate = endDate.AddDays(1)
End If
Dim query As String = "SELECT inDate1, inTime1 FROM loginlog WHERE personID = @PersonID AND inDate1 BETWEEN @StartDate AND @EndDate"
Dim mycon As New OleDbConnection(con)
Dim command As New OleDbCommand(query, mycon)
command.Parameters.Add(New OleDbParameter With {.ParameterName = "@PersonID", .OleDbType = OleDbType.VarWChar, .Value = TextBox1.Text})
command.Parameters.Add(New OleDbParameter With {.ParameterName = "@StartDate", .OleDbType = OleDbType.Date, .Value = startDate})
command.Parameters.Add(New OleDbParameter With {.ParameterName = "@EndDate", .OleDbType = OleDbType.Date, .Value = endDate})
' now execute the query...
。
将ABUnknownPersonViewController推送到现有的UINavigationController。