我有一個tableview與章節。第一節有4行與標籤在其中。 在第二和第三部分我有自定義按鈕。第四部分我想顯示 mapview來顯示user.does的當前位置任何人有任何想法我該怎麼做。 任何教程或示例代碼?如何在tableview單元格中顯示mapview的分段?
回答
YOu需要設置代理&在cellView的contentView中添加mapView。
#import <MapKit/MapKit.h>
MKMapView *mapView;
NSString *locationStr;
MKAnnotationView *annotationView;
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
if(indexPath.section ==3)
{
Initialize & alloc memory to Object of MKMapView
[cell.contentView addSubView:mapView]; //Add it to cells contentView
}
return cell;
}
要在MapView。使用該委託的方法降譯註:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>) annotation{
// Use this method for placing custom Annotation in MapView
}
希望這將解決您的問題。
我已經通過插入以下代碼解決了這個問題:mapView = [[MKMapView alloc] initWithFrame:frame22]; \t \t \t mapView.mapType = MKMapTypeStandard; \t \t \t CLLocationCoordinate2D location = mapView.userLocation.coordinate; \t \t \t MKCoordinateSpan span; \t \t \t MKCoordinateRegion region; \t \t \t \t \t \t location.latitude = [[aVolunteer latitude] floatValue]; \t \t \t location.longitude = [[aVolunteer longitude] floatValue]; \t \t \t mapView.scrollEnabled = YES; \t \t \t span.latitudeDelta = 0.05; \t \t \t span.longitudeDelta = 0。05; – nehal 2011-03-23 12:05:17
你是否已經在mapView中使用了mapView中的單元格或任何其他方式?因爲你應該在UITableView中使用它;;) – 2011-03-23 13:20:32
我已經聲明瞭子視圖像這樣UIView * subView = [[UIView alloc] initWithFrame: CGRectMake(10,0,300,45)]; 然後在第4部分 情況3: \t \t \t subView.backgroundColor = [UIColor whiteColor]; [subView insertSubview:[self loadMap] atIndex:0]; cell1.backgroundView = subView; [subView release]; 然後在loadmap函數中寫上面的註釋代碼 – nehal 2011-04-13 13:16:01
- 1. TableView顯示空單元格
- 2. 如何在ipad中顯示彈出窗口單元格中的tableview單元格
- 3. TableviewCell中的TableView不顯示單元格
- 4. 如何在tableview單元格顯示之前顯示佔位符?
- 5. 如何在tableview單元格文本框中顯示光標
- 6. 突出顯示特定tableview部分中的所有單元格
- 7. 如何在點擊單元格時顯示tableview單元格編輯視圖?
- 8. 如何獲取TableView單元格中顯示的數據並將其顯示在文本字段中?
- 9. TableView不顯示單元格內容
- 10. TableView顯示空白單元格
- 11. Swift TableView單元格不顯示
- 12. 如何擴大tableview單元格自身對齊顯示整個單元格
- 13. 顯示數組從plist在tableview單元格中的問題
- 14. 在tableview中顯示兩個可重用的單元格Swift 3
- 15. tableview單元格中的顯示活動指示器
- 16. 我如何調整與分組的單元格tableview中的單元格
- 17. 在TableView的每個單元格上的分段控件
- 18. 在tableview單元格中突出顯示uiwebview文本
- 19. 如何在單擊該特定單元格時將tableview單元格的數據顯示給另一個viewcontroller?
- 20. Tableview單元格不顯示整數格式的數據
- 21. 在tableview單元格上的彈出窗口顯示
- 22. tableview中的最後一個單元格未完全顯示
- 23. iPhone SDK - 突出顯示TableView中選定的單元格
- 24. TableView不顯示單元格中的內容(Swift)
- 25. 如何從tableview中檢查單元格?
- 26. 如何將對象分配給TableView中的單元格?
- 27. 在xamarin.ios中顯示在tableview中的一行中的多個原型單元格
- 28. 如何正確顯示單元格中的分數Word 2010
- 29. 如何顯示在熱圖單元格中的數值單元格的值
- 30. 在TableView結尾處顯示單元格數量
] mapView = [[MKMapView alloc] initWithFrame:frame22]; \t \t \t mapView.mapType = MKMapTypeStandard; \t \t \t CLLocationCoordinate2D location = mapView.userLocation.coordinate; \t \t \t MKCoordinateSpan span; \t \t \t MKCoordinateRegion region; \t \t \t \t \t \t location.latitude = [[aVolunteer latitude] floatValue]; \t \t \t location.longitude = [[aVolunteer longitude] floatValue]; \t \t \t mapView.scrollEnabled = YES; \t \t \t span.latitudeDelta = 0.05; \t \t \t span.longitudeDelta = 0.05; – nehal 2011-03-23 12:04:22