apple watch的project是要綁在手機上的專案,
所以watch app其實只是手機app的延伸,
若你今天要啟用apple watch simulator的話,
只要在xcode的target選擇watch app
然後按下compile
模擬器就會跑出來囉!
若你發現只有手機模擬器出現的話,
你可以在模擬器的工具列
Hardware→External Displays→選到最下方的Apple Watch
這樣Apple watch的simulator就會跑出來囉!
git config http.sslVerify false
Error:error: pathspec 'src/com/aaaa/bbbb/cccc/dddd/DMF.java' did not match any file(s) known to git.
during executing git commit --only -F /private/var/folders/6h/zv5mh4px15d6yjksw693q_s40000gp/T/git-commit-msg-5225757047314811222.txt -- src/com/aaaa/bbbb/cccc/dddd/DMF.java
git commit -m commitMessage
PackageManager pm = mContext.getPackageManager();
List<applicationinfo> appList = pm.getInstalledApplications(0);
for(ApplicationInfo app: appList )
{
Log.i("info","app:" + app );
if( app.packageName.equals(LINE_PACKAGE_NAME))
{
return true;
}
}
intent.setAction(Intent.ACTION_SEND);
intent = mContext.getPackageManager().getLaunchIntentForPackage(AppConfig.LINE_PACKAGE_NAME);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "this is test! oh ya!");
mContext.startActivity(intent);
<intent-filter >
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="text/plain" />
</intent-filter >
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewTag viewTag;
if (convertView == null) {
convertView = layoutInflater.inflate(R.layout.layout_item, null);
viewTag = new ViewTag((TableLayout) convertView.findViewById(R.id.tableLL),
(TextView) convertView.findViewById(R.id.question));
convertView.setTag(viewTag);
}
else
{
viewTag = (ViewTag) convertView.getTag();
viewTag.tableLL.removeAllViews();
}
NSLog(@"%@", NSStringFromSelector(_cmd));
_cmd在objective-c都為一個SEL<!DOCTYPE html>
<html>
<head>
<script>
function callObjFunction()
{
return "I will return from js web";
}
</script>
</head>
<body>
</body>
</html>
NSString *str = [_theWebview stringByEvaluatingJavaScriptFromString: [NSString stringWithFormat:@"callObjFunction()"]];
NSLog(@"str:%@", str);
sudo apachectl start
/Library/WebServer/Documents/
啟用php功能
/etc/apache2/httpd.conf
LoadModule php5_module libexec/apache2/libphp5.so
sudo apachectl restart
cd ; vi .bash_profile
export PATH="/usr/local/mysql/bin:$PATH"
source ~/.bash_profile
mysqladmin -u root password '你要登入mysql的密碼'
sudo mkdir /var/mysql
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock
$cfg['blowfish_secret'] = ‘這是cookie的內容隨便打 ’; /* YOU MUST FILL IN THIS FOR COOKIE AUTH! */
[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裡面的網頁囉~