的MKMapView一个UITableViewCell
问题描述:
里面我有一个包含的MKMapView UITableViewCells一个UITableView。的MKMapView一个UITableViewCell
问题是:如果表格单元格曾经被选中,然后移动地图,你看到的MapView全白了,你只看到了“法律”的标签。
有没有人遇到过这个?
这里是整个代码:
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.table.backgroundColor = [UIColor clearColor];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
return 70;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
MKMapView *map = [[MKMapView alloc] initWithFrame:CGRectMake(0, 0, 220, 70)];
MKCoordinateSpan span = MKCoordinateSpanMake(0.01, 0.01);
CLLocationCoordinate2D logCord = CLLocationCoordinate2DMake(47.606, -122.332);
MKCoordinateRegion region = MKCoordinateRegionMake(logCord, span);
[map setRegion:region animated:NO];
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"aaaa"];
[cell.contentView addSubview:map];
return cell;
}
答
我曾经历过这一点。
以我的情况下,地图变成白色像这样,如果其的tableView或小区具有的backgroundColor及其电池具有无论是灰色或蓝色选择风格和细胞通过出队再循环。
我认为,地图也不会变白这样如果
cell.selectionStyle = UITableViewCellSelectionStyleNone;
答
我曾经历过这一点。
我的地图了,当它被推/弹出另一个细节视图控制器后触及白色背景。 TableView没有配置颜色/背景,一切都是默认的。
cell.selectionStyle = UITableViewCellSelectionStyleNone;
......实际上有帮助。
我已经试过了,可以证实,没有解决不了的问题。 – vgr 2013-02-14 00:09:59
啊,确定究竟是什么导致我的情况下的白色地图是在viewWillAppear中设置self.tableView.backgroundColor。 在viewDidLoad中设置tableView的backgroundColor不会产生问题。 单元格的选择风格并不重要。 – Eric 2013-02-14 04:33:48
在情况下,如果你的使用笔尖为的UITableViewCell那么它可能是笔尖有selectionStyle设置的东西比被设定编程不同,这可以帮助任何人。当调用cellForRowAtIndexPath(其中cell.selectionStyle以编程方式设置)时,nib可能尚未加载,然后将选择样式重置为nib中的值。 – Duncan 2013-10-17 08:12:13