2018年4月25日 星期三

獲取UIWebView的內容高度

// 直接抓
CGSize newSize = [webView.scrollView contentSize];
webViewHeightConstraint.constant = newSize.height;

// 如果是單純本地端的html,這樣比較準
CGFloat webViewHeight = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.offsetHeight"] floatValue];
textViewHeightConstraint.constant = webViewHeight;

2018年4月18日 星期三

設定用UIModalPresentationFormSheet推出之後的視窗尺寸

categoriesViewController.preferredContentSize = CGSizeMake(440.0, 320.0);
categoriesViewController.modalPresentationStyle = UIModalPresentationFormSheet;

2018年4月13日 星期五

get mode name

#import <sys/utsname.h>

    struct utsname systemInfo;
    uname(&systemInfo);
    NSString *currentDeviceModel = [NSString stringWithCString:systemInfo.machine encoding:NSUTF8StringEncoding];