2013年11月28日
cellForRowAtIndexPathでセルがつくれない
MessageListCell *Cell;
Cell = (MessageListCell *)[self.tblMain cellForRowAtIndexPath: delegateJSON.indexPath];
の様な使い方でセルを作成して後から表示させるようなときに、テーブルの表示から呼び出した処理(ここではdelegateJSONでJSONの取得)を完全に非同期にしないと、セルはさくせいされない。理由はよくわからないですが、3時間ほどはまったので、メモ
Cell = (MessageListCell *)[self.tblMain cellForRowAtIndexPath: delegateJSON.indexPath];
の様な使い方でセルを作成して後から表示させるようなときに、テーブルの表示から呼び出した処理(ここではdelegateJSONでJSONの取得)を完全に非同期にしないと、セルはさくせいされない。理由はよくわからないですが、3時間ほどはまったので、メモ
2013年09月22日
データのソート
今日は少しデータのソートで悩んでしまったので、メモです。
自分のソースを貼付けてるだけなので、他の人には参考にならないと思いますが。すいません。
- (IBAction)setSendList:(id)sender{
strSelectedIDs = nil;
NSArray *sortedArray = [[NSArray alloc]initWithArray:[friendsDatas sortedArrayUsingFunction:compareInfo context:NULL]];
for (int i=0; i<[sortedArray count]; i++) {
DataFriends *bookData = (DataFriends *)[sortedArray objectAtIndex:i];
if (bookData.intDoSend==1) {
if (strSelectedIDs != nil) {
[strSelectedIDs appendString:@","];
}
[strSelectedIDs appendString:[NSString stringWithFormat:@"%d",bookData.primaryKey]];
}
}
[self.delegate SelectFriendViewControllerDidOK:self];
}
NSInteger compareInfo(id aInfo1, id aInfo2, void *context)
{
int dpercent1 = ((DataFriends*) aInfo1).primaryKey;
int dpercent2 = ((DataFriends*) aInfo2).primaryKey;
if (dpercent1 < dpercent2)
return NSOrderedDescending;
else if (dpercent1 > dpercent2)
return NSOrderedAscending;
else
return NSOrderedSame;
}
自分のソースを貼付けてるだけなので、他の人には参考にならないと思いますが。すいません。
- (IBAction)setSendList:(id)sender{
strSelectedIDs = nil;
NSArray *sortedArray = [[NSArray alloc]initWithArray:[friendsDatas sortedArrayUsingFunction:compareInfo context:NULL]];
for (int i=0; i<[sortedArray count]; i++) {
DataFriends *bookData = (DataFriends *)[sortedArray objectAtIndex:i];
if (bookData.intDoSend==1) {
if (strSelectedIDs != nil) {
[strSelectedIDs appendString:@","];
}
[strSelectedIDs appendString:[NSString stringWithFormat:@"%d",bookData.primaryKey]];
}
}
[self.delegate SelectFriendViewControllerDidOK:self];
}
NSInteger compareInfo(id aInfo1, id aInfo2, void *context)
{
int dpercent1 = ((DataFriends*) aInfo1).primaryKey;
int dpercent2 = ((DataFriends*) aInfo2).primaryKey;
if (dpercent1 < dpercent2)
return NSOrderedDescending;
else if (dpercent1 > dpercent2)
return NSOrderedAscending;
else
return NSOrderedSame;
}
2013年08月24日
xCodeで今日の0時のNSDateを取得
よく使うのですが、結構忘れるのでメモです。
NSCalendar *cal=[NSCalendar currentCalendar];
NSUInteger flags = NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit;
NSDate * tmpDate =[NSDate dateWithTimeInterval:-[[NSTimeZone systemTimeZone] secondsFromGMT] sinceDate:[NSDate date]]; //->これを入れとかないと、グリニッジ標準時刻になってしまう
NSDateComponents *cmp = [cal components:flags fromDate:tmpDate];
NSDate* date_converted;
// NSDateFormatter を用意します。
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
// 変換用の書式を設定します。
[formatter setDateFormat:@"YYYY-MM-dd"];
[formatter setDateFormat:@"yyyy-MM-dd"]; //YYYYだとどうしてか、去年になってしまいます。
// NSString を NSDate に変換します。
date_converted = [formatter dateFromString:[NSString stringWithFormat:@"%04d-%02d-%02d",[cmp year],[cmp month],[cmp day]]];
// 使い終わった NSDateFormatter を解放します。
[formatter release];
NSCalendar *cal=[NSCalendar currentCalendar];
NSUInteger flags = NSYearCalendarUnit
| NSMonthCalendarUnit
| NSDayCalendarUnit;
NSDate * tmpDate =[NSDate dateWithTimeInterval:-[[NSTimeZone systemTimeZone] secondsFromGMT] sinceDate:[NSDate date]]; //->これを入れとかないと、グリニッジ標準時刻になってしまう
NSDateComponents *cmp = [cal components:flags fromDate:tmpDate];
NSDate* date_converted;
// NSDateFormatter を用意します。
NSDateFormatter* formatter = [[NSDateFormatter alloc] init];
// 変換用の書式を設定します。
[formatter setDateFormat:@"
[formatter setDateFormat:@"yyyy-MM-dd"]; //YYYYだとどうしてか、去年になってしまいます。
// NSString を NSDate に変換します。
date_converted = [formatter dateFromString:[NSString stringWithFormat:@"%04d-%02d-%02d",[cmp year],[cmp month],[cmp day]]];
// 使い終わった NSDateFormatter を解放します。
[formatter release];
2013年06月15日
iPhoneアプリでviewがずれる現象
iPhone5が登場する前に作ったアプリをこれに対応さそうとして、xibファイルを色々触っても、思ったようにならないとき、
デリゲートファイルでのdidFinishLaunchingWithOptionsのところで
[_window addSubview:_viewController.view];
となっている(古いパターン)場合があります。
このときは
self.window.rootViewController = self.viewController;
と変更してやると、うまく行きました。
他の原因もありそうですが、これで解決したのでメモしておきます。
デリゲートファイルでのdidFinishLaunchingWithOptionsのところで
[_window addSubview:_viewController.view];
となっている(古いパターン)場合があります。
このときは
self.window.rootViewController = self.viewController;
と変更してやると、うまく行きました。
他の原因もありそうですが、これで解決したのでメモしておきます。
2013年04月25日
アップルのアプリ内課金の審査
アップルのアプリの審査はどんどん、厳しくなってるような気がします。
それか、私が時々変なアプリを提出するから目を付けられてるかもしれませんww
ただ、アプリ内課金に関してはほんとに厳しくなってるようです。
今回はリストア処理を忘れて、英語で理由を返されて、意味不明な状態になったので、次回以降のためにメモっときます。
We found that while your app offers In-App Purchase(s) that can be restored, it does not include the required “Restore” feature to allow users to restore the previously purchased In-App Purchase(s), as specified in Restoring Transactions section of the In-App Purchase Programming Guide:
“…if your application supports product types that must be restorable, you must include an interface that allows users to restore these purchases. This interface allows a user to add the product to other devices or, if the original device was wiped, to restore the transaction on the original device.”
To restore previously purchased In-App Purchase products, it would be appropriate to provide a “Restore” button and initiate the restore process when the “Restore” button is tapped by the user.
For more information about restoring transactions and verifying store receipt, please refer to the In-App Purchase Programming Guide.
という文章が帰って来たのですが、一度購入したユーザーが再度購入するときのための処理を実装しなさいということらしいです。
http://maccle.com/objective-c-cocoa/rejected-in-order-to-restore-in-app-purchase/
や、参考書を参考にして、うまくいきましたが、
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
の前に
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
を行っていなかったので、処理結果が帰ってこずに、結構ハマってしまいましたので、次回から注意です。
ちなみに、このことを実装したら審査通りました。ありがとうございます!!
それか、私が時々変なアプリを提出するから目を付けられてるかもしれませんww
ただ、アプリ内課金に関してはほんとに厳しくなってるようです。
今回はリストア処理を忘れて、英語で理由を返されて、意味不明な状態になったので、次回以降のためにメモっときます。
We found that while your app offers In-App Purchase(s) that can be restored, it does not include the required “Restore” feature to allow users to restore the previously purchased In-App Purchase(s), as specified in Restoring Transactions section of the In-App Purchase Programming Guide:
“…if your application supports product types that must be restorable, you must include an interface that allows users to restore these purchases. This interface allows a user to add the product to other devices or, if the original device was wiped, to restore the transaction on the original device.”
To restore previously purchased In-App Purchase products, it would be appropriate to provide a “Restore” button and initiate the restore process when the “Restore” button is tapped by the user.
For more information about restoring transactions and verifying store receipt, please refer to the In-App Purchase Programming Guide.
という文章が帰って来たのですが、一度購入したユーザーが再度購入するときのための処理を実装しなさいということらしいです。
http://maccle.com/objective-c-cocoa/rejected-in-order-to-restore-in-app-purchase/
や、参考書を参考にして、うまくいきましたが、
[[SKPaymentQueue defaultQueue] restoreCompletedTransactions];
の前に
[[SKPaymentQueue defaultQueue] addTransactionObserver:self];
を行っていなかったので、処理結果が帰ってこずに、結構ハマってしまいましたので、次回から注意です。
ちなみに、このことを実装したら審査通りました。ありがとうございます!!
2013年04月20日
コンパイル時のエラー
今回は、zbarというバーコードを読み取るsdkを実装したときのコンパイルエラーについてです。
そのままでも、iPhone5以外は動作したのですが、iPhone5でだけビルドエラーになりました。
file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/imae/Desktop/ZBarSDK/libzbar.a for architecture armv7s
というような、エラーメッセージです。
このような場合はBuildSettingでArchiteturesをStandard(armv7,armv7s)からarmv7に変更したらビルドできました。
このビルドエラーは厄介で色んなパターンがあるのですが、今回解決した方法をメモしておきます。
そのままでも、iPhone5以外は動作したのですが、iPhone5でだけビルドエラーになりました。
file is universal (3 slices) but does not contain a(n) armv7s slice: /Users/imae/Desktop/ZBarSDK/libzbar.a for architecture armv7s
というような、エラーメッセージです。
このような場合はBuildSettingでArchiteturesをStandard(armv7,armv7s)からarmv7に変更したらビルドできました。
このビルドエラーは厄介で色んなパターンがあるのですが、今回解決した方法をメモしておきます。
2013年04月19日
手書き文字認識
今日は新しいネタを見つけましたので、そのことをメモしときます。
zinniaっていうのを使うと、アプリに手書き認識を手軽に実装できそう。
http://d.hatena.ne.jp/kaz_29/20111214/1323841470
オーダリングの端末として使うにはいいかもです。
zinniaっていうのを使うと、アプリに手書き認識を手軽に実装できそう。
http://d.hatena.ne.jp/kaz_29/20111214/1323841470
オーダリングの端末として使うにはいいかもです。
プロフィール
けん
S | M | T | W | T | F | S |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
最近の記事
cellForRowAtIndexPathでセルがつくれない (11/28)
データのソート (9/22)
xCodeで今日の0時のNSDateを取得 (8/24)
画像ファイルの上書き (8/19)
バイクレース (8/11)
iPhoneアプリでviewがずれる現象 (6/15)
64bit版のコンパイル (5/31)
ALTER COLUMN (5/31)
アップルのアプリ内課金の審査 (4/25)
最近のコメント
ラクブロ編集長 / Kenの気ままな日記
お気に入り
ブログ内検索
QRコード

アクセスカウンタ
読者登録
人気の楽園ブログ