Home > iPhone SDK 3 Archive
iPhone SDK 3 Archive
NSTimeZone タイムゾーン
- 2010-07-29 (木)
- Object-C | iPhone | iPhone SDK 3 | iPhone SDK4
NSTimeZoneのクラスメソッド
- timeZoneWithName:・・・タイムゾーン名でタイムゾーンを作って返します
- timeZoneWithAbbreviation:・・・省略形からタイムゾーンを作って返します
- timeZoneForSecondsFromGMT:・・・グリニッジ標準時からの秒差でタイムゾーンを作って返します
次のソースで、timeZoneWithNameの、タイムゾーン名を取得できます。
#import <CoreFoundation/CoreFoundation.h> NSString *timeZoneinfo = (NSString *)CFTimeZoneCopyKnownNames(); NSLog(@"timeZoneinfo is %@", timeZoneinfo);
例えば、
- ニューヨーク・・・“America/New_York”
- 上海・・・“Asia/Shanghai”
- 東京・・・“Asia/Tokyo”
- ロンドン・・・“Europe/London”
- Comments: 0
- Trackbacks: 0
iPhoneアプリ ステータスバーを消す
- 2010-03-29 (月)
- Object-C | iPhone | iPhone SDK 3

1. 動的にステータスバーを消す、色を変更させる
- (void)viewDidLoad
{
// スーパー・クラスのメソッドを呼び出す
[super viewDidLoad];
//ステータスバー off
[[UIApplication sharedApplication] setStatusBarHidden:YES];
| setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:YES | ステータスバーを黒くする |
|---|---|
| setStatusBarHidden:YES animated:YES | ステータスバーが上に引っ込む |
2. ローディング画面時の、ステータスバーを消す
しかし、上記のやり方だと、起動時にはステータスバーがデフォルトのままなので、全画面で変更したい場合、info.plistを編集しておきます。
XCode の/Resourceフォルダ info.plist を開き、
Information Property List キーの中に UIStatusBarStyle キーを作成する。
(Information Property List 行を control+クリック で Add Row を選択し、キー名を入力)
例)値をUIStatusBarStyleBlackOpaque =起動時からステータスバーの色が黒くなる。
2-1. ステータスバーを消したい場合

| UIStatusBarHidden | チェックすると、ステータスバー非表示 |
|---|
2-2. 色や透明度を変更したい場合

key: UIStatusBarStyleのValueの設定内容
| UIStatusBarStyleDefault | 標準(灰色) |
|---|---|
| UIStatusBarStyleBlackTranslucent | 黒く透ける |
| UIStatusBarStyleBlackOpaque | 黒くする |
- Comments: 0
- Trackbacks: 0
iPhoneアプリ UITableViewを試す。
- 2010-03-14 (日)
- Object-C | iPhone | iPhone SDK 3
「Macを買うなら…」でおなじみの、秋葉館オンラインショップ
もちろん話題のiPodも本体を含め関連商品充実! ![]()

色々と大変そうなので、避けていたのですが、
UITableViewの基礎を試してみました。
こちらをベースに色々カスタマイズしてみようと思います。
- tableView:cellForRowAtIndexPath: メソッド
indexPathが指定する位置のUITableViewCellのインスタンスを返すようにする。 - tableView:numberOfRowsInSection: メソッド
テーブルが保持するセルの数を返すようにする。
iPhone Dev Center: UITableViewDataSource Protocol Referenceより
@implementation RootViewController
- (void)viewDidLoad {
[super viewDidLoad];
self.title =@"UITableView 聖域十二宮編";
//Tableに表示する要素
items_ = [[NSArray alloc] initWithObjects:
@"1月 山羊座 - Capricornus", @"2月 水瓶座 - Aquarius",@"3月 魚座 - Pisces",
@"4月 牡羊座 - Aries", @"5月 牡牛座 - Taurus", @"6月 双子座 - Gemini",
@"7月 蟹座 - Cancer", @"8月 獅子座 - Leo", @"9月 乙女座 - Virgo",
@"10月 天秤座 - Libra", @"11月 蠍座 - Scorpio", @"12月 射手座 - Sagittarius",
nil];
}
<pre>//Viewのリリースに、要素の配列をリリース</pre>
- (void)viewDidUnload {
[items_ release];
}
// テーブルが持っているセルの数を返す
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [items_ count];
}
// UiTableViewCellのインスタンスを返す
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
// Configure the cell.
cell.textLabel.text = [items_ objectAtIndex:indexPath.row];
return cell;
}

セルの選択時にアクションを発生させるには、didSelectedRowAtIndexPathメソッドをオーバライドします。
// セルの選択をハンドリングしてアクションを発生させる
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString* message = [items_ objectAtIndex:indexPath.row];
UIAlertView* alert = [[[UIAlertView alloc] init] autorelease];
alert.message = message;
[alert addButtonWithTitle:@"OK"];
[alert show];
}
- Comments: 0
- Trackbacks: 0
Home > iPhone SDK 3 Archive