LocalSoftwareKeyboardController, FocusRequester の2クラスを使う
LocalSoftwareKeyboardControllerを取得して、show/hideメソッドをコールする
@Composable
fun sample() {
val keyboardController = LocalSoftwareKeyboardController.current
func getURL(ofPhotoWith mPhasset: PHAsset, completionHandler : @escaping ((_ responseURL : URL?) -> Void)) { | |
if mPhasset.mediaType == .image { | |
let options: PHContentEditingInputRequestOptions = PHContentEditingInputRequestOptions() | |
options.canHandleAdjustmentData = {(adjustmeta: PHAdjustmentData) -> Bool in | |
return true | |
} | |
mPhasset.requestContentEditingInput(with: options, completionHandler: { (contentEditingInput, info) in | |
completionHandler(contentEditingInput!.fullSizeImageURL) | |
}) |
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// by calling [NSURLProtocol registerClass:[MyURLProtocol class]]; in -application:didFinishLoadingWithOptions:, your protocol will have priority over any of the built-in protocols. | |
URLProtocol.registerClass(ActivityURLProtocol.self) | |
//URLProtocol.unregisterClass(ActivityURLProtocol.self) | |
print(URLSession.shared.configuration.protocolClasses) | |
} |
" 日本語入力設定 | |
if has('multi_byte_ime') || has('xim') | |
" IME ON時のカーソルの色を設定(設定例:紫) | |
highlight CursorIM guibg=Purple guifg=NONE | |
" 挿入モード・検索モードでのデフォルトのIME状態設定 | |
set iminsert=0 imsearch=0 | |
" 挿入モードでのIME状態を記憶させない | |
inoremap <silent> <ESC> <ESC>:set iminsert=0<CR> | |
endif |
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { | |
let text = collections[indexPath.row].name | |
let width = UILabel.textWidth(font: titleFont, text: text) | |
return CGSize(width: width + left + right, height: height) | |
} |
extension UIView { | |
func roundCorners(_ corners: CACornerMask, radius: CGFloat) { | |
if #available(iOS 11, *) { | |
self.layer.cornerRadius = radius | |
self.layer.maskedCorners = corners | |
} else { | |
var cornerMask = UIRectCorner() | |
if(corners.contains(.layerMinXMinYCorner)){ | |
cornerMask.insert(.topLeft) |
extension Array { | |
func chunked(by chunkSize: Int) -> [[Element]] { | |
return stride(from: 0, to: self.count, by: chunkSize).map { | |
Array(self[$0..<Swift.min($0 + chunkSize, self.count)]) | |
} | |
} | |
} | |
let arr = [0,1,2,3,4,5,6,7,8,9] | |
print(arr.chunked(by: 2)) // [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] |
// How to: | |
// 1. Open the Firebase Analytics Dashboard | |
// 2. Scroll to bottom, where you see the "Users by Device model" widget | |
// 3. Click "View device models" in that widget (this opens the "Tech details" Firebase Analytics page) | |
// 4. Above the table shown in the new page, click on the “Device model” drop down menu and select “OS with Version” | |
// 5. Make sure to select “OS with version” and not “OS Version” | |
// 6. On the top right corner of the page, click on the “Share this report” icon (next to the date) | |
// 7. Click “Download file” on the new side bar, then “Download CSV" | |
// 8. Open the file and select the iOS/Android breakdown raw data | |
// 9. Replace the sample data in this script with your data |
import PlaygroundSupport | |
import SwiftUI | |
import Combine | |
class ObservableObject1: ObservableObject { | |
@Published var name: String = "src" | |
} | |
struct ContentView1: View { | |
@ObservedObject private var object = ObservableObject1() |
import Combine | |
import UIKit | |
public protocol CombineCompatible {} | |
// MARK: - UIControl | |
public extension UIControl { | |
final class Subscription<SubscriberType: Subscriber, Control: UIControl>: Combine.Subscription where SubscriberType.Input == Control { | |
private var subscriber: SubscriberType? | |
private let input: Control |