经验随笔objective-C

<一>设置输入框UITextField只可以输入固定长度

    [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(textFieldChanged:)
                                             name:UITextFieldTextDidChangeNotification

//执行方法为

-(void)textFieldChanged:(id)text{
    if (self.phoneNum.text.length > 11) {  //设置可输入11位
    self.phoneNum.text = [self.phoneNum.text substringToIndex:11];
    }
}

<二>实现从页面底部推出页面:
使用页面跳转模态实现:

loadingViewController *loadingVC = [[loadingViewController alloc] init];
[self presentViewController:loadingVC animated:YES completion:^{  //在当前界面推出 loadingViewController界面
}];

//在loadingViewController界面中取消推出界面, 回到原界面

[self dismissViewControllerAnimated:YES completion:^{
  }];

<三>实现UITextField中粘帖为汉字
在程序的Info.plist中将其设置为china如下:
这里写图片描述

<四>关于tableView中cell的有关设置
点击时cell的背景图片,系统默认的有(即cell选中时的样式)
1.无色 cell.selectionStyle = UITableViewCellSelectionStyleNone;
2.蓝色 cell.selectionStyle = UITableViewCellSelectionStyleBlue;
3.灰色 cell.selectionStyle = UITableViewCellSelectionStyleGray;

也可以自定义点击时cell的背景图片
cell.selectedBackgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@”btn_two_hover”]];

自定义点击时cell的背景颜色
cell.selectedBackgroundView = [[UIView alloc] initWithFrame:cell.frame];
cell.selectedBackgroundView.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];

点击时cell的字体颜色
cell.textLabel.highlightedTextColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1];

设置cell间的分割线颜色
[theTableView setSeparatorColor:[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:1 ]];

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值