只要打入[UIColor 後面就會跳出顏色面版讓你選擇
不用再自行輸入色彩代碼
如圖
安裝使用方式
只要下載官網專案檔
使用xcode開啟專案 compile 成功後
程式會自動在你的
加入外掛
目前官網說明在 OS X 10.8 with Xcode 4.4.1 and 4.5.的環境測試過
而我是在OS X 10.9.4 withXCode 5.1 and Xcode 6 Beta3 測試皆可以使用。
[self.navigationController popToRootViewController]
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:2] animated:YES];
for (UIViewController *controller in self.navigationController.viewControllers) {
if ([controller isKindOfClass:[你要跳到的UIViewController的class名稱 class]]) {
[self.navigationController popToViewController:controller animated:YES];
}
}
[GMSMapView animateToCameraPosition:]: unrecognized selector sent to instance
webview.setWebChromeClient(new WebChromeClient());
webview.addJavascriptInterface(new JavaScriptInterface(), "android");
function executeFromObjCall(str)
{
alert("execute from objective c call params:" + str);
}
webview.loadUrl("javascript:executeFromObjCall('passValue');");
function callJavaFunction()
{
var str = window.android.callJavaMethod();
alert(str);
}
public class JavaScriptInterface {
public String callJavaMethod() {
Log.i("info", "called from javascript execute in java");
return "this is return params from java";
}
}
<!DOCTYPE html>
<html>
<head>
<script>
function callObjFunction()
{
var jsParam = "paramFromJs";
window.location = 'js-call:runObjMethod:';
}
</script>
</head>
<body>
<button onclick="callObjFunction()">call obj function</button>
</body>
</html>
然後在我們的xcode裡objective-c 建立被呼叫的function
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *urlString = request.URL.absoluteString;
// 判斷點下的網址是否有js-call,更精確應該再比對切出來的字串是否有runObjMethod
if( [urlString hasPrefix:@"js-call:"])
{
[self runObjMethod];
return NO;
}
return YES;
}
-(void) runObjMethod
{
NSLog(@"this is objective-c method");
}
p.s. 如果你要javascript帶傳參數到objective-c的話,就js-call:param1:param2
然後去parse出param1,param2的內容就可以~
若要回傳參數的話(objective -> javascript)
我們先把原本的HTML的javascript 內新增
function jsFunction(str)
{
alert("this is javascript alert! -> obj2 pass value to js show:"+str);
}
在objective-c內的runObjMethod function下加入
// 方法1
NSString *myval = @"my parameters from objective-c";
// javascript 的function 名稱 與obj變數組合成字串
NSString *jsMethod = [NSString stringWithFormat:@"%@%@%@", @"jsFunction('", myval, @"')"];
[_myWebView stringByEvaluatingJavaScriptFromString:jsMethod];
// 或
// 方法2
[_myWebView stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"jsFunction('%@')",myval ]];
這樣就可以將objective-c的參數 傳到UIWebview裡面的網頁囉~