您的位置:首页 > 移动开发 > IOS开发

iOS-基本知识汇总

2015-08-05 10:20 393 查看
1.隐藏按钮
sender.hidden = YES;
2.按钮常用基础知识
//获取按钮指定状态下的文字
NSString *text = [sender titleForState:UIControlStateNormal];
//获取当前状态下的文字
NSString *text = sender.currentTitle;
//按钮是否可用
sendBtn.enabled = YES/NO;
3.控制view层上的按钮控件是否可以点击
self.optionsView.userInteractionEnabled = YES/NO;
4.UIAlertView用法
//弹出一个对话框
UIAlertView * msgView = [[UIAlertView alloc] initWithTitle:@"操作提示" message:@"恭喜您过关啦"delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", @"哈哈",nil];
//显示对话框
[msgView show];
//监控UIAlertView某个按钮需要代理UIAlertViewDelegate,
//实现UIAlertView的代理方法
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSLog(@"%ld",buttonIndex);
}
5.UITableView,一般当数据少于屏幕的高度时候,下方会有多余的tableViewCell.解决办法:
self.tableView.tableFooterView = [[UIView alloc] init];
6.图片变成圆形,需要设置其属性key path:
layer.masksToBounds  Boolean   yes
layer.cornerRadius       Number   25(图片尺寸的1/2)
iOS-基本知识汇总 - lightingbolt - lightingbolt的博客
7.textField赋值
[self.contactText setText:@""];
7.UIView展示的几种形式,推出(push),模态(由底部向上弹出)
a).push:
XNewsReviewViewController* reviewVc = [[XNewsReviewViewController alloc] init];
[self.navigationController pushViewController:reviewVc animated:YES];
b).模态
XNewsSettingViewController * settingVc=[[XNewsSettingViewController alloc] init];
XNewsNavigationController *nav = [[XNewsNavigationController alloc] initWithRootViewController:settingVc];
[self presentViewController:nav animated:YES completion:^{

}];
9.tableViewCell相关
a).系统默认箭头
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; //显示最右边的箭头
b).选中tableViewCell时候去掉选中效果
cell.selectionStyle = UITableViewCellSelectionStyleNone;
lightingBolt
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: