iOS开发--将一个tablevirew塞进callout中

默认callout的只有一个title和detailtextlabel,所显示的信息量实在太小,虽然在地图中弹出一个小框显示一点关键信息很合理,但是有些客户需要框变大一点,信息量多一个那也是没有办法的。

效果:

 

我采取的方法是直接将一个tableview塞进去,但是tableView根本不能直接塞进calliout中,但可以将一个view塞进callout,我用的方法就是将tableview加到一个view上,然后在塞进callout中,上代码:

                self.mapView.callout.accessoryButtonHidden = YES;
                self.mapView.callout.accessoryButtonType=UIButtonTypeCustom;
                self.mapView.callout.color=[UIColor whiteColor];
                self.mapView.callout.customView=nil;
                UIView*view=[UIView new];
                view.frame=CGRectMake(0, 0, 170, 170);
                view.backgroundColor=[UIColor redColor];
                [self.xtbTableView removeFromSuperview];
                //self.mapView.callout.customView=view;
                self.xtbTableView=nil;
                self.xtbTableView=[UITableView new];
                self.xtbTableView.frame=view.frame;
                [self.xtbTableView setBackgroundColor:[UIColor yellowColor]];
                self.xtbTableView.dataSource=self;
                self.xtbTableView.delegate =self;
                [self.xtbTableView reloadData];
                [view addSubview:self.xtbTableView];
                self.mapView.callout.customView=view;
                CGRect rect=  self.mapView.callout.customView.frame;
                [self.mapView.callout.customView setFrame:rect];
                [self.mapView.callout showCalloutAt:xtbPoint screenOffset:CGPointZero animated:NO];
                self.mapView.touchDelegate=self; 
posted on 2016-06-18 15:24  sandyLoveCoding  阅读(155)  评论(0编辑  收藏  举报