expectでsudoを使いたい時に、タイムアウトに応じてパスワードプロンプトが出たり出なかったりするのが困ります。 そんな時は、

   1  % sudo -k

で強制的にタイムアウトさせることができるので、 一旦タイムアウトさせた後にパスワードプロンプトを待つようにするとうまくいきます。

ちなみに、パスワードプロンプトのメッセージを統一したい場合は、

   1  % sudo -p password: ls
   2  password:

のように-pオプションで指定できます。

posted by Png genki on Wed 17 Nov 2010 at 18:36

自分の 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
Contents
expect と sudo の問題の解決方法
TabBarController+NavigationController+multi orientation
tabBarController:shouldSelectViewController:
Comments
瀧内元気: MacOS版は以下にあります * [genki/ViMouse](https://githu... '23-1
KingofSmack: Here also good reads for this mobile applicatio... '14-5
Spencer: You don't have to re-compile it, this version w... '14-4
staiano: Any chance we can get a recompile for 10.9? '14-1
dsjf: https://gist.github.com/6bf1bf2c3cbb5eb6e7a7 これ... '13-1
Services from s21g
twpro(ツイプロ)
Twitterプロフィールを快適検索
地価2009
土地の値段を調べてみよう
MyRestaurant
自分だけのレストラン手帳
Formula
ブログに数式を埋め込める数式コミュニティ