• 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
 
 

自分の view が表示される前に別のタブで回転されている可能性があるので、回転に対応する処理をプログラムで行う場合は viewWillAppear の中でも処理を行わなくてはならない。

   1  @implementation SomeViewController
   2  
   3  -	(BOOL)
   4  shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
   5  	return YES;
   6  }
   7  
   8  -	(void)
   9  AdjustHV {
  10  	switch ( self.interfaceOrientation ) {
  11  	case UIInterfaceOrientationPortrait:
  12  	case UIInterfaceOrientationPortraitUpsideDown:
  13  		oV1.frame = CGRectMake(
  14  			0
  15  		,	0
  16  		,	self.view.frame.size.width
  17  		,	self.view.frame.size.height / 2
  18  		);
  19  		oV2.frame = CGRectMake(
  20  			0
  21  		,	self.view.frame.size.height / 2
  22  		,	self.view.frame.size.width
  23  		,	self.view.frame.size.height / 2
  24  		);
  25  		break;
  26  	case UIInterfaceOrientationLandscapeLeft:
  27  	case UIInterfaceOrientationLandscapeRight:
  28  		oV1.frame = CGRectMake(
  29  			0
  30  		,	0
  31  		,	self.view.frame.size.width / 2
  32  		,	self.view.frame.size.height
  33  		);
  34  		oV2.frame = CGRectMake(
  35  			self.view.frame.size.width / 2
  36  		,	0
  37  		,	self.view.frame.size.width / 2
  38  		,	self.view.frame.size.height
  39  		);
  40  		break;
  41  	}
  42  }
  43  
  44  -	(void)
  45  viewWillAppear:(BOOL)p {
  46  	[ super viewWillAppear:p ];
  47  	[ self AdjustHV ];
  48  }
  49  
  50  -	(void)
  51  willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)p
  52  duration:(NSTimeInterval)pDuration {
  53  	[ super willAnimateRotationToInterfaceOrientation:p duration:pDuration ];
  54  	[ self AdjustHV ];
  55  }
  56  @end

posted by Face Saturn on Wed 17 Nov 2010 at 09:56

UITabBarController の中で UINavigationController を使っていて、その中で pushViewController で遷移している時に、それ自身の Tab をタップすると、navigationController が rootViewController に戻ってしまう。 これを避けるには UITabBarController の delegate をつなぎ、その delegate の中で以下のように自分自身かどうかを判断して YES/NO を返すようにする。

11/22 加筆 moreNavigationController がある場合、more のタブを2回タップすると、selectedIndexが NSNotFound になってくる。その対処を加えた。

   1  -	(BOOL)
   2  tabBarController:(UITabBarController*)pTBC
   3  shouldSelectViewController:(UIViewController*)p {
   4      return pTBC.selectedIndex < pTBC.viewControllers.count
   5  	?	[ pTBC.viewControllers objectAtIndex:pTBC.selectedIndex ] != p
   6  	:	YES
   7  	;
   8  }

posted by Face Saturn on Wed 17 Nov 2010 at 06:36

NSOperationQue は(当然のことながら)別スレッドで動くので 中の NSOperation からUIKit を扱うときは performSelectorOnMainThread を使用してやりたい処理をメインスレッドにスケジュールしてやる。

   1  @interface	Operation : NSOperation {
   2  }
   3  @end
   4  @implementation	Operation
   5  -	(void)
   6  Sub {
   7  NSLog( @"Sub:%@", [ NSThread currentThread ] );
   8      //  UIKit を使う処理
   9  }
  10  
  11  -	(void)
  12  main {
  13  NSLog( @"main:%@", [ NSThread currentThread ] );
  14  	[ self performSelectorOnMainThread:@selector(Sub) withObject:nil waitUntilDone:NO ];
  15  }
  16  @end
  17  
  18  
  19  {
  20  	NSOperationQueue*	w = [ [ [ NSOperationQueue alloc ] init ] autorelease ];
  21  	[ w addOperation:[ [ Operation alloc ] init ] ];
  22  }

posted by Face Saturn on Tue 16 Nov 2010 at 02:29

info.plist の Localization native development region で 'Japan' を指定すると 'その他' に変わる。

posted by Face Saturn on Thu 11 Nov 2010 at 07:58

iPhone キーボードの大きさの最大値は

// Portrait 320.000000,216.000000 // Landscape 480.000000,162.000000

これを超して作ったものを inputView にセットしても、このエリアからはみ出す部分はタップが来ない。

これより小さく作った場合、UIViewAutoresizingFlexibleHeight がセットされていると、この大きさに高さがリサイズされる。

幅は常にリサイズされる。

どうしても大きいのを作りたかったら、inputView と inputAccessoryView の両方を使う。

posted by Face Saturn on Thu 28 Oct 2010 at 07:29

一般に nib で指定したアウトレットは initWithCode が呼ばれたタイミングではまだつながれておらず awakeFromNib が呼ばれたタイミングではつながれている。

UIViewController の注意事項 Nib A で指定された UIViewController (以下vc)が Nib B からview を読むようになっているとき、vc の view は awakeFromNib でもつながれていない。(NIb A で指定していないから当然なのだが。)view プロパティに読み込みアクセスするときに Nib B からのロードが行われ、その時点で view はつながれ、その後、viewDidLoad が呼ばれる。

表示しなくても view プロパティにさえアクセスしてやればロードされる。 self.view; の1文でロードされる。どのタイミングでロードされるかはデバッガで _view を見る。ダンプしようとするとロードされてしまう。

posted by Face Saturn on Thu 28 Oct 2010 at 01:17

application does not run in background を info.plist で指定すると UIApplicationExitsOnSuspend がセットされる

posted by Face Saturn on Wed 27 Oct 2010 at 09:17

Important: iOS ignores this cache policy, and instead treats it as NSURLCacheStorageAllowedInMemoryOnly.

Disk にキャッシュする機能は iPhone では 提供されていない。自前でなんとかしなくちゃいけないらしい。

キャッシュのキャパシティを設定しておかないと willCacheResponse は呼ばれない。

キャッシュのキャパシティの設定: [ [ NSURLCache sharedURLCache ] setMemoryCapacity:100000 ];

posted by Face Saturn on Wed 27 Oct 2010 at 02:13

UIScrollView で zoomScale を設定すると flashScrollIndicators が無効になる? flashScrollIndicators → zoomScale の順でやること。

posted by Face Saturn on Sat 23 Oct 2010 at 12:40

どれかを指定するとビューの大きさを変更できなくなる。

posted by Face Saturn on Thu 14 Oct 2010 at 08:24
Contents
TabBarController+NavigationController+multi orientation
tabBarController:shouldSelectViewController:
NSOperation が動くスレッド
TabBarController の More の言語
iPhone キーボードの大きさの最大値
Nib を読んで生成されるオブジェクトのアウトレット
UIApplicationExitsOnSuspend
NSURLCacheStoragePolicy/NSURLCacheStorageAllowed
zoomScaleとflashScrollIndicators
Simulated User Interface Elements
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ