accessoryview和ios accessorytypee不能共存吗

MKPinAnnotationView rightCalloutAccessoryView 不会发送 calloutAccessoryControlTapped iOS7
注意事项: 本文中文内容可能为机器翻译,如要查看英文原文请点击上面连接.
我想更新到 iOS7 我的应用程序之一。这一问题,在这,我 MKMapView ,当我点击一个 pin,它显示 Callout ,但当点击 rightCalloutAccessoryView ,它再也不会发送任何回调到委托。因此,我再也不能推详细信息视图。
它能正常工作在 iOS6,不会再在 iOS7 上。
下面是代码的相关段:
- (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id &MKAnnotation&)annotation {
if ([annotation isKindOfClass:[MKUserLocation class]]) {
NSString * annotationIdentifier =
if ([annotation isKindOfClass:VPStation.class]) {
annotationIdentifier = @"stationAnnotationIdentifier";
if (!annotation) {
MKPinAnnotationView * annotationView = [(MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:annotationIdentifier] retain];
if(annotationView == nil) {
annotationView = [[MKPinAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotationIdentifier];
annotationView.canShowCallout = YES;
annotationView.rightCalloutAccessoryView = [UIButton buttonWithType:UIButtonTypeDetailDisclosure];
annotationView.image = [UIImage imageNamed:@"MyAnnotationPin"];
annotationView.centerOffset = CGPointMake(-10.0f, 0.0f);
annotationView.annotation =
return [annotationView autorelease];
- (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)view calloutAccessoryControlTapped:(UIControl *)control {
if ([view.annotation isKindOfClass:VPStation.class]) {
VPTotalDetailViewController * detailVC = [[VPTotalDetailViewController alloc] initWithStation:(VPStation *)view.annotation
andUserLocation:self.mapView.userLocation.coordinate];
[self.navigationController pushViewController:detailVC animated:YES];
[detailVC release];
根据 MKAnnotationView 类的引用:
如果您指定的视图也是一个 UIControl 类的后裔,你可以使用地图查看委托您的控件被触碰时收到通知。如果不,它不降临从 UIControl,您的视图是负责处理在其边界内的任何触摸事件。
还有什么比把我自己简单的 UIView 子类获取触摸和推 detailViewController 吗?我应该等待苹果要修复此 bug 吗?我相信它是一个 bug,不是吗?
解决方法 1:
好了,这里的问题是我有 UIGestureRecognizer 上设置 MKMapView (价值,它是一个自定义识别器,但我不相信此更改什么) 和此笔势识别器消耗触摸,然后不转发到 calloutAccessoryControl 。请注意,此行为更改iOS6 和 iOS7 之间。此修复程序是很容易的虽然我作为识别器 (不是之前) 的委托,委托添加我的控制器和执行 UIGestureRecognizerDelegate 方法:
#pragma mark - UIGestureRecognizerDelegate
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
if ([touch.view isKindOfClass:[UIControl class]]) {
return NO;
return YES;rainbird2 的BLOG
用户名:rainbird2
文章数:285
评论数:1151
访问量:2051667
注册日期:
阅读量:5863
阅读量:12276
阅读量:318237
阅读量:1030270
51CTO推荐博文
&为了美化UI,想实现如下图的效果:点击高亮
出发点是好的。没想到,出现了下图的连带问题:选择一行的时候,竟然连带的出现了高亮效果
这个如何是好?经过网络搜索,发现我不是第一个遇到这样的问题:
UIButton&*accessoryButton&=&[UIButton&buttonWithType:UIButtonTypeCustom];&&&&&accessoryButton.frame&=&CGRectMake(0,&0,&32,&32);&&&&&[accessoryButton&setImage:[UIImage&imageNamed:@&AccessoryButtonNormal.png&]&forState:UIControlStateNormal];&&&&&[accessoryButton&setImage:[UIImage&imageNamed:@&AccessoryButtonInverse.png&]&forState:UIControlStateHighlighted];&&&&&[accessoryButton&addTarget:self&action:@selector(doAction:)&forControlEvents:UIControlEventTouchUpInside];&&&&&cell.accessoryView&=&accessoryB&
连使用方法都是一样的,看来我不是第一个这么干的。这哥哥也不给解决办法,不知道最后搞定没问题。困惑了一天以后,终于让我找到了一条小缝隙,实现了下图的效果:
这个点击行的时候,整行高亮是系统自带的功能,没办法改变,怎么办呢?釜底抽薪,在它高亮完以后再把效果取消!这个出发点是对的,可是浪费了大把的时间以后发现还是达不到预期的效果,怎么呢?查sdk的时候无意间发现UITablview有个willSelectRowAtIndexPath的方法吧。好吧,这个willSelectRowAtIndexPath比didSelectRowAtIndexPath应该靠前吧,在这里面试一下
-&(NSIndexPath&*)tableView:(UITableView&*)tableView&willSelectRowAtIndexPath:(NSIndexPath&*)indexPath{&&&&&UITableViewCell&*Cell&=&[tableView&cellForRowAtIndexPath:indexPath];&&&&&[(UIButton&*)Cell.accessoryView&setHighlighted:NO];&&&&&return&indexP&}&
开始直接用的上面的代码,发现好使靠人品,后来想想即然在这个地方可以,那就延时执行一下,于是用了:
-&(void)mySelectRow:(UIButton&*)actionBtn{&&&&&[actionBtn&setHighlighted:NO];&}&-&(NSIndexPath&*)tableView:(UITableView&*)tableView&willSelectRowAtIndexPath:(NSIndexPath&*)indexPath{&&&&&UITableViewCell&*Cell&=&[tableView&cellForRowAtIndexPath:indexPath];&&&&&[self&performSelector:@selector(mySelectRow:)&withObject:(UIButton&*)Cell.accessoryView&afterDelay:0];&&&&&return&indexP&}&
于是乎,好使了!
哎,一个小效果浪费了一天整的时间!本文出自 “” 博客,转载请与作者联系!
了这篇文章
类别:┆阅读(0)┆评论(0)
13:43:03 14:47:10 17:46:17 14:35:21TableViewCell AccessoryBuild Requirements:Runtime Requirements:
This sample demonstrates two methods that can be used to implement a custom accessory view in your UITableViewCell's.
In both examples, a custom control that implements a toggle-able checkbox is used.
The first method shows you how to override the appearance or control of the accessory view, much like that of "UITableViewCellAccessoryDetailDisclosureButton". It implements the custom accessory view by setting the table's "accessoryView" property with a custom control which draws a checkbox. It can be toggled by selecting the entire table row by implementing UITableView's "didSelectRowAtIndexPath". The checkbox is trackable (checked/unchecked), and can be toggled independent of table selection.
The second method shows how to implement a trackable-settable UIControl embedded in a UITableViewCell. This approach is handy if an application already uses its accessory view to the right of the table cell, but still wants a checkbox view that supports toggling states of individual row items. The checkbox on the left provides fulfills this need and is trackable (checked/unchecked) independent of table selection. This is a similar user interface to that of Mail's Inbox table where mail items can be individually checked and unchecked for deletion.
The checkbox is trackable (checked/unchecked), and can be toggled independent of table selection.
Sending feedback&
We&re sorry, an error has occurred.
Please try submitting your feedback later.
Thank you for providing feedback!
Your input helps improve our developer documentation.
How helpful is this document?
Very helpful
Somewhat helpful
Not helpful
How can we improve this document?
Fix typos or links
Fix incorrect information
Add or update code samples
Add or update illustrations
Add information about...
* Required information
To submit a product bug or enhancement request, please visit the
Please read
before you send us your feedback.ios 关于UITableView UITableViewCellAccessoryCheckmark 混乱的问题
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'自定义UITableViewCell中Accessory(已更新)
目前项目中需要用到自定义Cell及cell中的Acessory图片,期间碰到了一些不吐不快的槽,非常抱歉由于项目要赶进度,我只能每周挤点时间出来写写,让大家久等了,sorry。
// 设置Accessory
UIImage *imageAccessory = [UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@&icon_right& ofType:@&png&]];
UIButton *btnAccessory = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0f, 0.0f, imageAccessory.size.width, imageAccessory.size.height);
btnAccessory.frame =
[btnAccessory setBackgroundImage:imageAccessory forState:UIControlStateNormal];
[btnAccessory setBackgroundImage:imageAccessory forState:UIControlStateHighlighted];
btnAccessory.backgroundColor = [UIColor clearColor];
[btnAccessory addTarget:self action:@selector(btnClicked:event:) forControlEvents:UIControlEventTouchUpInside];
NSLog(@&btnAccessory = %@&, btnAccessory);
cell.accessoryView = btnA
NSLog(@&cell.accessoryView = %@&, cell.accessoryView);
#pragma mark - IBAction Methods
// 检查用户点击按钮时的位置,并转发事件到对应的accessory tapped事件
- (void)btnClicked:(id)sender event:(id)event
NSSet *touches = [event allTouches];
UITouch *touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:tableViewCustom];
NSIndexPath *indexPath = [tableViewCustom indexPathForRowAtPoint:currentTouchPosition];
// or instead with such below
// UITableViewCell *cell = (UITableViewCell *)sender.
if(indexPath != nil)
[self tableView:tableViewCustom accessoryButtonTappedForRowWithIndexPath:indexPath];
UIImage图片位置必须正确,一次手误打错路径,浪费了2分钟在上面,建议nslog一下以免产生坑爹的空值。
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath
关于UITableViewCellAccessoryType建议大家每一种都试一下,看看效果如何,但如果要自定义Accessory,这个方法基本上没啥鸟用。
用了以后还有可能迷惑你=。=
自定义Accessory时直接使用以下代码是没用的
accessoryButtonTappedForRowWithIndexPath:indexPath
所以需要增加一个SEL
[btnAccessory addTarget:self action:@selector(btnClicked:event:) forControlEvents:UIControlEventTouchUpInside];个人觉得可以再UITableViewCellAccessoryType中再增加一个自定义类型,然后直接映射到这个方法,省得麻烦啊~accessoryButtonTappedForRowWithIndexPath:indexPath
代码我会在周日前附上,先去吃饭了=。=
> 本站内容系网友提交或本网编辑转载,其目的在于传递更多信息,并不代表本网赞同其观点和对其真实性负责。如涉及作品内容、版权和其它问题,请及时与本网联系,我们将在第一时间删除内容!
自定义UITableViewCell的accessory样式 默认的accessoryType属性有四种取值:UITableViewCellAccessoryNone. UITableViewCellAccessoryDisclosureIndicator. UITableViewCellAccessoryDetailDisclosureButton. UI ...
通常我们在自定义一个UITableViewCell时,从网络上获取数据,传入到自定义tableviewcell类中,进行加载,运行程序之后,发现仍然没有数据显示: 这里我们以简单的数据源形式来做一次实验,如图所示: 这里_dataSource为NSArray的对象,CustomTableViewCell为自定义cell类,当前为viewcontroller
对于 UITableViewCell 而言,其 accessoryType属性有4种取值: UITableViewCellAccessoryNone, UITableViewCellAccessoryDisclosureIndicator, UITableViewCellAccessoryDetailDisclosureButton, UITableView ...
案例: 由于在应用开发过程中,需要实现一个功能:点击tableviewcell上的一个按钮,弹出popver窗口.为了设置弹出窗口箭头的准确位置,就必须知道坐标,这个坐标的计算的关键就在于获取该按钮所在cell的indexpath了. 难点: tableview在滚动时存在循环的问题,所以仅仅在初始化cell时将按钮的tag设置为[indexPath row ...
做机房收费系统的时候,最开始不知道机房收费系统的操作原理,就随便在数据库中填写东西,结果最终明白了系统的工作逻辑之后,想删除SQL中的一些数据结果出状况了!如下:
表现为在:数据库中出现了重复的键值或数据,当试图删除时错误提示信息就出来了.建立的几个表都没有关键字,设置好关键字后问题解决.
解决的方法:
-(IBAction)button:(id)sender{ UIButton* button = (UIButton*) UITableViewCell* buttonCell = (UITableViewCell*)[sender superview]; NSUInteger row = [[tableView indexPathForCel ...
UITableView的强大更多程度上来自于可以任意自定义UITableViewCell单元格. 通常,UITableView中的Cell是 动态的,在使用过程中,会创建一个Cell池,根据每个cell的高度(即tableView:heightForRowAtIndexPath:返回 值),以及屏幕高度计算屏幕中可显示几个cell.而进行自定义TableVi ...
如何动态调整Cell高度
1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
staticNSString*CellIdentifier=@&C ...

我要回帖

更多关于 accessorytype 颜色 的文章

 

随机推荐