Posts tagged controller
iPhone/iPad で各種ファイルを QuickLook する
0iOS4.0 から使える Quick Look フレームワークを試してみました。
画像、PDF、HTML、iWorks、MSOffice などのファイルのプレビューをしたり、印刷やファイル形式によって対応している他のアプリで開いたりすることができます。
UITableViewController などと同じようにデータソースを指定して、プレビューさせるファイルがいくつあるか、indexPath で指定されたファイルのファイルパスを返すなどを実装すれば簡単にプレビュー画面を作成できます。
(続きを読む…)
[iPhone 開発メモ] アプリ内で UIWebView を使って Web ページを表示する
7iPhoen アプリ内で Web ページを表示する方法です。UIWebView を使います。
UIWebViewを表示するためのシンプルなUIViewController – ちびり文
こちらのエントリを参考に IB を使ってやってみました。
(続きを読む…)
[iPhone 開発メモ] 本体の回転を検知する
1iPhone を横方向に回転させた時に検知する方法のメモです。
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)FromInterfaceOrientation {
if(FromInterfaceOrientation == UIInterfaceOrientationPortrait){
// 横向き
} else {
// 縦向き
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
[iPhone 開発メモ] 画像をドラッグする
5画面に表示された画像を指でドラッグする方法です。
UIImageView クラスを継承した DragView クラスを作成する。
@interface DragView : UIImageView {
CGPoint startLocation;
}
@end
@implementation DragView
- (void) touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event
{
startLocation = [[touches anyObject] locationInView:self];
[[self superview] bringSubviewToFront:self];
}
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
CGPoint pt = [[touches anyObject] locationInView:self];
CGRect frame = [self frame];
frame.origin.x += pt.x - startLocation.x;
frame.origin.y += pt.y - startLocation.y;
[self setFrame:frame];
}
@end;
CakePHP1.2 Security コンポーネントを使用して SSL でのみアクセスを許可する
0開発案件でアクション毎に SSL でのアクセスを必須にしたかったので調べていたところ下記の情報がありました。
SSL経由でのアクセスを必須にする[CakePHP] YARETOKO「ヤレトコ」メインブログ
早速 cake/cake/libs/controller/components/security.php のソースを確認して検証してみました。
(続きを読む…)
CakePHP1.2 SimpleTest の小技
0CakePHP で SimpleTest を使うときにちょっとした小技の紹介です。
<?php
class UsersControllerTestCase extends CakeTestCase {
function startCase() {
echo '<h1>Starting Test Case</h1>';
}
function endCase() {
echo '<h1>Ending Test Case</h1>';
}
function startTest($method) {
echo '<h3>Starting method '.$method.'</h3>';
}
function endTest($method) {
echo '<hr/>';
}
function testIndex() {
$result = $this->testAction('/users/index');
debug($result);
}
}
?>
CakePHP1.2 SimpleTest のテストケースをまとめて実行する
1ある程度テストケースが増えてくるといちいち App Test Cases からひとつづつテストを実行するのは面倒です。そこでグループ化してまとめてテストケースを実行する方法です。
テストケースのグループ化
app/tests/groups 以下に GroupTest を継承したクラスを作成する。
GroupTest を継承したクラスのファイル名は hoge.group.php のように .group.php を付ける。
まとめる対象はディレクトリかファイルを指定できる。
(続きを読む…)
CakePHP1.2 SimpleTest でコントローラのテストケースを作成
1CakePHP1.2 SimpleTest でテストケースを作成する ではモデルのテストケースを作成したので今度はコントローラのテストケースを作成してみました。
コントローラのテストケースは app/tests/case/conrollers 以下に作成します。
app/tests/case/conrollers/user_controller.test.php
<?php
class UsersControllerTestCase extends CakeTestCase {
function testIndexTitle() {
$result = $this->testAction('/users/index', array('return'=>'render'));
$this->assertPattern("/<title>TITLE<\/title>/", $result);
}
function testIndexSet() {
$result = $this->testAction('/users/index', array('return'=>'vars'));
$this->assertTrue(isset($result["users"]));
}
}
?>
CakePHP1.2 で追加されるコンポーネントの3つのコールバック関数
1New callback methods for components – cakebaker によると次にリリースされる CakePHP1.2 ではコンポーネントに3つのコールバック関数が追加されるようです。
beforeRender()
view のレンダリングの前、コントローラの beforeRender() メソッドの後に呼ばれる。
public function beforeRender($controller) {
}