标签:mystra ios uiview 停止交互 失去焦点
UIView停止交互(失去焦点):
设置userInteractionEnabled=NO, 获取交互设置YES.
可以应用于UIButton, UITextField等交互型控件.
[editButton setUserInteractionEnabled:YES];
editButton.userInteractionEnabled = NO;
实例:
#pragma mark ItemChooseViewDelegate
// 选择服务类型框
- (void) didSelectedItem {
NIDPRINTMETHODNAME();
_servicePos = _serviceItemListView.selectedIndex; // 设置Item位置
// 总价格
_totalPrice = (float)([_goodsList[_servicePos][@"Price"] floatValue]/100.0)*
[[_serviceNumList objectAtIndex:_servicePos] integerValue];
[_totalPriceLabel setText:[NSString stringWithFormat:@"%0.1f", _totalPrice]];
// 设置按钮状态
for (int i=0; i<_goodsList.count; ++i) {
// 选中
if (i == _servicePos) {
[[_titleLabelArray objectAtIndex:i] setTextColor: [UIColor blackColor]];
[[_priceLabelArray objectAtIndex:i] setTextColor: RGBCOLOR_HEX(0xff6000)];
[[_timesFieldArray objectAtIndex:i] setTextColor: [UIColor blackColor]];
[[_timesFieldArray objectAtIndex:i] setUserInteractionEnabled: YES];
[[_addBtnArray objectAtIndex:i] setUserInteractionEnabled:YES];
[[_subBtnArray objectAtIndex:i] setUserInteractionEnabled:YES];
continue;
}
// 未选中
[[_titleLabelArray objectAtIndex:i] setTextColor: [UIColor grayColor]];
[[_priceLabelArray objectAtIndex:i] setTextColor: [UIColor grayColor]];
[[_timesFieldArray objectAtIndex:i] setTextColor: [UIColor grayColor]];
[[_timesFieldArray objectAtIndex:i] setUserInteractionEnabled: NO];
[[_addBtnArray objectAtIndex:i] setUserInteractionEnabled:NO];
[[_subBtnArray objectAtIndex:i] setUserInteractionEnabled:NO];
}
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
标签:mystra ios uiview 停止交互 失去焦点
原文地址:http://blog.csdn.net/caroline_wendy/article/details/46866173