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

IOS 开发技巧,小细节,注意事项

2015-09-08 00:00 706 查看
// textFieldShouldReturn 函数写了,但是按键到 return 无法让键盘消失

因为你的文本框没有添加委托。添加委托的方法,右键文本框,把 outlets 下的+拉到 file's owner上就可以了。 或者在加载事件中添加 textFeild.delegate=self;

// numberOfRowsInSection 问题

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1; // 当返回值为 0 时,- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {} 不会渲染执行
}

// tableView 没有数据

可能是 tableView没有绑定事件,或者在加载事件中添加 self.tableView.delegate = self;self.tableView.dataSource = self;

//添加事件对象

self.tableView.target = self;

//单击方法

self.tableView.action = @selector(singleClickAction:);

//允许空 Selection

self.tableView.allowsEmptySelection = YES;

//webView 载入网页时 页面过大,不自适应,可通过下面代码使 webview 自适应大小

[webView setScalesPageToFit:YES]

//下面两种可以隐藏键盘

1、[view endEditing:YES] 这个方法可以让整个view取消第一响应者,从而让所有控件的键盘隐藏。

2、[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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: