2012-02-23 9 views
1

長時間のlurker初めてのポスター単純なAndroidプロジェクトをXcodeで実行するように変換する

私はiOS上で動作するように求められている簡単なアンドロイドプロジェクトを持っています。私はすべてのプログラマ、タスクのためにボランティアを迅速にあるネットワークだけの男ではないよ...

だから、これは私が(Eclipseプロジェクトに)オフ動作するように与えられているものです:

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 

    // Add Click listeners for all buttons 
    View firstButton = findViewById(R.id.button1); 
    firstButton.setOnClickListener(this); 
    View secondButton = findViewById(R.id.button2); 
    secondButton.setOnClickListener(this); 
    View thirdButton = findViewById(R.id.button3); 
    thirdButton.setOnClickListener(this); 
    View fourthButton = findViewById(R.id.button4); 
    fourthButton.setOnClickListener(this); 
    View fifthButton = findViewById(R.id.button5); 
    fifthButton.setOnClickListener(this); 
} 

// Process the button click events 
public void onClick(View v) { 

    //based on the button clicked display associated html file 
    //html files are located under the assets folder 
    switch(v.getId()){ 
     case R.id.button1: 
      Intent j = new Intent(this, Webscreen.class); 
      j.putExtra(Webscreen.URL, "file:///android_asset/deliver.html"); 
      startActivity(j); 
     break; 

     case R.id.button2: 
      Intent k = new Intent(this, Webscreen.class); 
      k.putExtra(Webscreen.URL, "file:///android_asset/return.html"); 
      startActivity(k); 
     break; 

     case R.id.button3: 
      Intent l = new Intent(this, Webscreen.class); 
      l.putExtra(Webscreen.URL, "file:///android_asset/updating.html"); 
      startActivity(l); 
     break; 

     case R.id.button4: 
      Intent m = new Intent(this, Webscreen.class); 
      m.putExtra(Webscreen.URL, "file:///android_asset/repair.html"); 
      startActivity(m); 
     break; 

     case R.id.button5: 
      Intent n = new Intent(this, Webscreen.class); 
      n.putExtra(Webscreen.URL, "file:///android_asset/vendor.html"); 
      startActivity(n); 
     break; 
    } 

これはすべて画面上の5つのボタンを表示し、クリックするとローカルのHTMLファイルを開きます。

誰かがXcodeで何か似たようなことをする良い例がありますか?私はWebビューで作業しようとしていますが、あまりにも多くの運がまだありません。私はスコアボードを使って何かを手に入れることができましたが、このアプリは以前のバージョンのiOSでは価値があり、5.0でなくてはなりません。

ありがとうございました/すべてのヘルプ!

答えて

0

あなたはプログラマではないと言っているので、どこから始めたらいいのか分かりません。最も簡単な方法は、Safariでこれらのhtmlファイルを開くだけです。必要なのは、htmlファイルを持つhtmlサーバーだけです。これは、あなたがそれを行うことができる方法である。

NSString *urlString = [NSString stringWithFormat:@"http:///yourdomain/deliver.html"]; 
NSURL * url = [NSURL URLWithString:urlString]; 
[[NSWorkspace sharedWorkspace] openURL:url]; 

あなたはWebViewのを使用したい場合は、これはあなたがビューにファイルをロードする方法である:

-(void)loadDocument:(NSString*)documentName inView:(UIWebView*)webView 
{ 
    NSString *path = [[NSBundle mainBundle] pathForResource:documentName ofType:nil]; 
    NSURL *url = [NSURL fileURLWithPath:path]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
    [webView loadRequest:request]; 
} 

// Calling -loadDocument:inView: 
[self loadDocument:@"deliver.html" inView:self.webview]; 

あなたがして、プロジェクトにあなたのhtmlファイルを追加することができますXcodeの左側にあるナビゲータリストにドラッグ&ドロップするだけです。シートが表示されます。 「ファイルをコピー...」を選択して、ターゲットの横にあるチェックボックスをオンにしてください。

webView変数は、Interface Builderで定義したWebviewです。あなたはコンセントを使用してこれを設定: https://developer.apple.com/library/mac/#recipes/xcode_help-interface_builder/CreatingOutlet.html

編集:は、ボタンをクリックしたときにメソッドをトリガできるアクションを使用します。 ここで、行動の詳細を確認できます: https://developer.apple.com/library/ios/#documentation/IDEs/Conceptual/Xcode4TransitionGuide/InterfaceBuilder/InterfaceBuilder.html

関連する問題