ios学习笔记
界面跳转
let vr = MyViewController(nibName: "MyViewController", bundle: nil)
vc.labelContent = input.text
self.presentModalViewController(vc, animated: true);
//将我们的storyBoard实例化,“Main”为StoryBoard的名称
UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:@"Me" bundle:nil];
//将第二个控制器实例化,"SecondViewController"为我们设置的控制器的ID
ReceiptAddressVC *vc = [mainStoryBoard instantiateViewControllerWithIdentifier:@"ReceiptAddressVC"];
[self.navigationController pushViewController:vc animated:YES];
返回到上一页面
复制文本到剪切板
UIPasteboard *pasteboard = [UIPasteboard generalPasteboard];
pasteboard.string = self.label1.text;pasteboard.string = self.label1.text;
方法二
/// 测试剪切板,实现代码拷贝内容
func testPasteBoard(str:String) {
//就这两句话就实现了
let paste = UIPasteboard.general
paste.string = str
}
获取剪切板内容
监听剪切板变化
2,复制字符串数组
UIPasteboard.general.strings = ["hellow", "hangge.com"]
3,复制图片
let image = UIImage(named: "logo.png")
UIPasteboard.general.image = image
websocket连接
自定义view
关闭软键盘
self.userNameTF = [[UITextField alloc] init];
[self.view addSubview:self.userNameTF];
//在需要关闭键盘时调用
[self.userNameTF resignFirstResponder];
方法二
加入如下方法:
- (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[usernameTextFiled resignFirstResponder ];
[passwdTextFiled resignFirstResponder ];
}
swift代码
方法一
对单个的UITextField调用resignFirstResponder方法, 使其失去第一响应者
sender.resignFirstResponder()
方法二
对UIViewController,重写touchesBegan, 并调用endEditing方法
override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
view.endEditing(true)
}
使用流布局
使用滚动布局
解析json
http网络请求
get请求
post请求
显示gif图片
保存数据 读取数据
image显示网络图片
storyboard界面跳转
单文件界面跳转