// textFieldShouldReturn 函数写了,可是按键到 return 没法让键盘消失
web
由于你的文本框没有添加委托。添加委托的方法,右键文本框,把 outlets 下的+拉到 file's owner上就能够了。 或者在加载事件中添加 textFeild.delegate=self;函数
// numberOfRowsInSection 问题ui
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1; // 当返回值为 0 时,- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {} 不会渲染执行
}spa
// tableView 没有数据代理
多是 tableView没有绑定事件,或者在加载事件中添加 self.tableView.delegate = self;self.tableView.dataSource = self;orm
//添加事件对象对象
self.tableView.target = self;事件
//单击方法图片
self.tableView.action = @selector(singleClickAction:);webview
//容许空 Selection
self.tableView.allowsEmptySelection = YES;
//webView 载入网页时 页面过大,不自适应,可经过下面代码使 webview 自适应大小
[webView setScalesPageToFit:YES]
//下面两种能够隐藏键盘
一、[view endEditing:YES] 这个方法能够让整个view取消第一响应者,从而让全部控件的键盘隐藏。
二、[textFiled resignFirstResponder] 这个则是比较经常使用的让某个textFiled的键盘隐藏。
//点击 view 空白 触发
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
[view endEditing:YES];
//[textFiled resignFirstResponder];
}
//获取系统版本号为 8.0 以上
([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
//手动调用 tableView 的点击事件
[self tableView:_tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForRow:2 inSection:0]];
// 设置 view 圆角
view.layer.masksToBounds=YES;// [_label.layer setMasksToBounds:YES];
view.layer.cornerRadius = 5;
//页面传值方式
(属性,代理,block,单例,通知)
//window 覆盖状态栏
UIWindow* window = [uiwindow new];
window.windowLevel = UIWindowLevelStatusBar + 1000;
[window addSubview:self];
//iOS之用 NSTimer 避免倒计时按钮的文字闪烁的办法
将UIButton的类型由system改成custom
//经过文件路径读取图片
NSString *path =[[NSBundle mainBundle] pathForResource:@"map" ofType:@"png"];
UIImage *image = [UIImage imageWithContentsOfFile:path];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];