【iOS】起動時にUIAlertを出して評価ページに飛ばす


起動時に「このアプリを評価してください」とUIAlertにと出したい話。

NewImage

こういう場合は、didFinishLaunchingWithOptionsにUIAlertについての記述をすれば良い。

- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    CGRect frameForWindow = [[UIScreen mainScreen] bounds];
    window = [[UIWindow alloc] initWithFrame:frameForWindow];

    //write about window
    //ウインドウについて記載

    [window addSubview:navigationController.view];

    //From here about UIAlert and rating popup.
    //manage displaying UIAlert by NSUserDefaults
    //ここからUIAlertについて記載。表示するかどうかはNSUserDefaultsで制御する。
    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    NSInteger executeTime = [userDefaults integerForKey: @"executeTime"];
    NSInteger alertDispFlag = [userDefaults integerForKey: @"alertDispFlag"];

    executeTime++;

    //If this application is started 6 times or more and alertDispFlag == 0, then alert is displayed.
    //もし6回以上起動していて、alertDispFlagが0なら表示する
    if (executeTime > 5 && alertDispFlag == 0) {
        // アラート表示

        UIAlertView *alertView = [[UIAlertView alloc] init];
        alertView.delegate = self;
        alertView.title=NSLocalizedString(@"pleaseReview", @"Please Rate");
        alertView.message=NSLocalizedString(@"appliciate", @"Please Rate this apps.");
        [alertView addButtonWithTitle:NSLocalizedString(@"Review", @"Rate now.")];
        [alertView addButtonWithTitle:NSLocalizedString(@"Later", @"Remind me later.")];
        [alertView addButtonWithTitle:NSLocalizedString(@"nothanks", @"No, thanks.")];
        [alertView show];
        [alertView release];

    }

    [userDefaults setInteger:executeTime forKey: @"executeTime"];
    [userDefaults synchronize];

    return YES;
}

//UIAlartのデリゲート。UIAlertの動作を記載する。
//delegate to UIAlret

-(void)alertView:(UIAlertView*)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex {

    NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
    switch (buttonIndex) {
        case 0:
            //go to rate page
            [userDefaults setInteger: 1 forKey: @"alertDispFlag"];
            [userDefaults synchronize];
            [[UIApplication sharedApplication] openURL:[NSURL URLWithString:NSLocalizedString(@"reviewURL", @"") ]];
            break;

        case 1:

            break;
        case 2:
            [userDefaults setInteger: 1 forKey: @"alertDispFlag"];
            [userDefaults synchronize];
            break;
    }

}

review URLは、

itms-apps://itunes.apple.com/WebObjects/MZStore.woa/wa/viewContentsUserReviews?id=(数字9桁のapp id)&onlyLatestVersion=true&pageNumber=0&sortOrdering=1&type=Purple+Software

です。

Arduino uno + ethernet shield + iPhone + iOSC(OSC Application)


Arduino uno にethernet shieldを乗っけて、iPhoneアプリのiOSCから、OSCのUDPパケットを受信してArduinoに接続された液晶を変更するスケッチ。

液晶接続のポートですが、最初

LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

としてたら液晶が表示されなかったので、下のスケッチのようにしたら動くようになりました。接続ポートに注意。また、UDPの受信コードはExamplesのUDPSendReceiveStringを参考にしました。というかそのまんま使いました。

/*
  UDPSendReceive.pde:
 */

#include          // needed for Arduino versions later than 0018
#include
#include          // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#include 

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[]	= { 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
byte ip[]	= { 192 , 168 , 1 , 1 } ;  //

unsigned int localPort = 10000;      // local port to listen on

// the next two variables are set when a packet is received
byte remoteIp[4];        // holds received packet's originating IP
unsigned int remotePort; // holds received packet's originating port

// buffers for receiving and sending data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
char  ReplyBuffer[] = "acknowledged";       // a string to send back
LiquidCrystal lcd(8, 7, 6, 5, 4, 3, 2);

void setup() {
  // start the Ethernet and UDP:
  Ethernet.begin(mac,ip);
  Udp.begin(localPort);

  lcd.begin(16,2);
  lcd.clear();
  lcd.setCursor(0, 0);

  Serial.begin(9600);
}

void loop() {
  // if there's data available, read a packet
  int packetSize = Udp.available(); // note that this includes the UDP header
  if(packetSize)
  {
    packetSize = packetSize - 8;      // subtract the 8 byte header
    Serial.print("Received packet of size ");
    Serial.println(packetSize);

    // read the packet into packetBufffer and get the senders IP addr and port number
    Udp.readPacket(packetBuffer,UDP_TX_PACKET_MAX_SIZE, remoteIp, remotePort);
    char* c = packetBuffer;
    if( strcmp(c, "/osc/button1") == 0 ){
      lcd.setCursor(0,0);
      lcd.print("button 1 pushed");
    }
    if ( strcmp(c, "/osc/button2") == 0 ){
      lcd.setCursor(0,0);
      lcd.print("button 2 pushed");
    }
    Udp.sendPacket( ReplyBuffer, remoteIp, remotePort);
  }
  delay(500);
}

iPhone Programming : OpenCV + AVFoundation – First step of AR


OpenCV + AVFoundation – First step of AR
カメラからリアルタイムキャプチャして,OpenCVでFFTしたスペクトルをだすプログラム.
ARはこんなところから始まるんでしょう,という例です.

プロジェクトのダウンロード(Xcode Project – Source)

こんな感じのプログラムです.下の方に表示されているのはプレビュー画像,上がスペクトルです.

このプログラムに対して,samurai-appsは一切責任を持ちません.自己責任で,またサンプルとして利用してください.

隠レター 公開開始


samurai-appsは本日,iPhone/iPod Touch/iPadアプリ 隠レター・隠Readerをリリースしました.

隠レターは,いわゆる電子透かしアプリです.自分の撮った,あるいはカメラロールにある写真に,自分の指で描いた秘密の画像を埋め込むことができます.埋め込んだ画像は受け取り手の隠レターで抽出することができます.秘密の通信に使いましょう.6月25日までは無料キャンペーンをしておりますので,ダウンロードして頂き,ぜひご感想をお寄せください.

隠Readerは,抽出に特化した無料アプリです。秘密の画像を受け取っても、これさえあればその秘密の画像を見ることができます。

詳しくはこちらから!

開発はObjective-Cはもちろんのこと,今回はOpenCVを使って書いています.画像処理はやはりOpenCVに任せてしまうのがいいですね.しかし,iPhone3Gで計算速度を出すのが大変でした.インタフェースにはまだまだ改良の余地がありますが,ぜひ電子透かしの新しい使い方を模索してみてください.

Calolog FREE 公開開始


ご好評いただいているCalolog(カロログ)の無料配布版を本日,公開しました.

機能的な制限はありませんが,広告が出ます.

今後ともsamurai-appsをよろしくお願い申し上げます.

Calolog FREE (iTunes)

アイデアの小槌+ Build 20091007.00 公開

5秒の強制思考時間のON/OFFを選択できるようになりました.

アイデアの小槌/アイデアの小槌+ Build 20090811.00 公開

続きを読む

© 2012 samurai-apps. All rights reserved. Powered by WordPress Entries RSS Comments RSS