首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

透过NSNotificationCenter更改被选中的背景色

2012-06-26 
通过NSNotificationCenter更改被选中的背景色1,通过NSNotificationCenter注册监听事件?[[NSNotificationCe

通过NSNotificationCenter更改被选中的背景色

1,通过NSNotificationCenter注册监听事件

?

[[NSNotificationCenter defaultCenter] addObserver:self                                             selector:@selector(menuWillShow:)                                                 name:UIMenuControllerWillShowMenuNotification                                               object:nil];
?

?

2,当UIMenu 显示的时候调用以下方法

?

- (void) menuWillShow:(NSNotification *)notification{    self.selectionStyle = UITableViewCellSelectionStyleBlue;    if ((self.delegate != nil) && [self.delegate respondsToSelector:@selector(emailableCell:selectCellAtIndexPath:)]) {        [self.delegate emailableCell:self selectCellAtIndexPath:self.indexPath];    }    [[NSNotificationCenter defaultCenter] removeObserver:self                                                    name:UIMenuControllerWillShowMenuNotification                                                  object:nil];    [[NSNotificationCenter defaultCenter] addObserver:self                                             selector:@selector(menuWillHide:)                                                 name:UIMenuControllerWillHideMenuNotification                                               object:nil];}

3,当UIMenu 消失的时候调用以下方法

?

- (void) menuWillHide:(NSNotification *)notification{    if ((self.delegate != nil) && [self.delegate respondsToSelector:@selector(emailableCell:deselectCellAtIndexPath:)]) {        [self.delegate emailableCell:self deselectCellAtIndexPath:self.indexPath];    }    self.selectionStyle = UITableViewCellSelectionStyleNone;    [[NSNotificationCenter defaultCenter] removeObserver:self                                                    name:UIMenuControllerWillHideMenuNotification                                                  object:nil];}
?

热点排行