iPhone SDK メモ
スタンフォード大で iPhone 開発講座とコードが公開されていたらしいが,今は削除されている.
UIFont *font = [UIFont fontWithName:@"HiraKakuProN-W3" size:12.0]; cell.font = font;
ちなみに iPhone に入っているフォントは
American Typewriter
* AmericanTypewriter * AmericanTypewriter-Bold
AppleGothic?
* AppleGothic
Arial
* ArialMT * Arial-BoldMT * Arial-ItalicMT * Arial-BoldItalicMT
Arial Rounded MT Bold
* ArialRoundedMTBold
Arial Unicode MS
* ArialUnicodeMS
Courier
* Courier * Courier-Bold * Courier-Oblique * Courier-BoldOblique
Courier New
* CourierNewPSMT * CourierNewPS-BoldMT * CourierNewPS-ItalicMT * CourierNewPS-BoldItalicMT
DB LCD Temp
* DBLCDTEmpBlack
Georgia
* Georgia * Georgia-Bold * Georgia-Italic * Georgia-BoldItalic
Helvetica
* Helvetica * Helvetica-Bold * Helvetica-Oblique * Helvetica-BoldOblique
Helvetica Neue
* HelveticaNeue * HelveticaNeue-Bold
Hiragino Kaku Gothic ProN W3
* HiraKakuProN-W3
Hiragino Kaku Gothic ProN W6
* HiraKakuProN-W6
Marker Felt
* MarkerFelt-Thin
STHeiti J
* STHeitiJ-Light * STHeitiJ-Medium
STHeiti K
* STHeitiK-Light * STHeitiK-Medium
STHeiti SC
* STHeitiSC-Light * STHeitiSC-Medium
STHeiti TC
* STHeitiTC-Light * STHeitiTC-Medium
Times New Roman
* TimesNewRomanPSMT * TimesNewRomanPS-BoldMT * TimesNewRomanPS-ItalicMT * TimesNewRomanPS-BoldItalicMT
Trebuchet MS
* TrebuchetMS * TrebuchetMS-Bold * TrebuchetMS-Italic * TrebuchetMS-BoldItalic
Verdana
* Verdana * Verdana-Bold * Verdana-Italic * Verdana-BoldItalic
Zapfino
* Zapfino
UI ロックスクリーン用に
* LockClock-Light
電話のダイヤル用に
* PhonepadTwo
return [[ array objectAtIndex:section] count]
cex.text = [[ array objectAtIndex:indexPath.section]
objectAtIndex:indexPath.row]
return cell;
でいけるだろう。
こういう方法も紹介されている.
componentsSeparatedByString関数が指定されたトークンで文字列を区切って配列を返すので,とりあえずこうする.
string = [[string componentsSeparatedByString:@"\n"]
objectAtIndex:0];
ただし "\n" は Macintoshではoptions キーを押しながら円マークで入力
失敗すると FALSE が返ってくる.
if([ @"" intValue] == TRUE)
下の エラー処理 [#m7be4e64]
int syntaxType = [anObject intValue];
if (syntaxType == -1) {
// エラー。例外を発生させる。
[self release];
[NSException
raise:NSInvalidUnarchiveOperationException format:
@"fail to decode"];
}
で、うまくいくかと思いきや。いかぬことがある。
さまざまな情報があって錯綜している。ここにも長い議論があるが、とりあえずはここにあるように使ってみる。
と思ったが,うまくいかないので,チェックしたセクションと行を配列に記憶させ,テーブルがクリックされるたびに [tableView reloadData] で初期化を行うことにした.reloadData 処理には,いろいろ問題もあるようであるが,今のところ,ちゃんと動いている.
Now i have another problem, when i select one and i scroll down. I see that some others are selected to. A bit strange.
You must be using a reuseIdentifier. When you go to return a cell, make sure to set it's accessoryType to the one without the checkmark unless you know it should be checked.
- (NSIndexPath *)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
SeismicXMLAppDelegate *appDelegate =
(SeismicXMLAppDelegate *)[[UIApplication sharedApplication]
delegate];
[appDelegate showEarthquakeInfo:
[(TableViewCell *)[tableView
cellForRowAtIndexPath:indexPath] quake]];
[[tableView cellForRowAtIndexPath: oldIndexPath]
setAccessoryType:UITableViewCellAccessoryNone];
[[tableView cellForRowAtIndexPath: indexPath]
setAccessoryType:UITableViewCellAccessoryCheckmark];
oldIndexPath = indexPath;
return nil;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *MyIdentifier = @"MyIdentifier";
TableViewCell *cell = (TableViewCell *)[tableView
dequeueReusableCellWithIdentifier:MyIdentifier];
if(indexPath == oldIndexPath){
cell.accessoryType =
UITableViewCellAccessoryCheckmark;
}else{
cell.accessoryType = UITableViewCellAccessoryNone;
}
if (cell == nil) {
cell = [[[TableViewCell alloc]
initWithFrame:CGRectZero reuseIdentifier:MyIdentifier]
autorelease];
}
// Set up the cell.
SeismicXMLAppDelegate *appDelegate =
(SeismicXMLAppDelegate *)[[UIApplication sharedApplication]
delegate];
// If the RSS feed isn't accessible (which could happen if
the network isn't available), show an informative
// message in the first row of the table.
if ([appDelegate isDataSourceAvailable] == NO) {
cell = [[[UITableViewCell alloc] initWithFrame:
CGRectZero reuseIdentifier:@"DefaultTableViewCell"]
autorelease];
cell.text = NSLocalizedString(@"RSS Host Not Available",
@"RSS Host Not Available message");
cell.textColor = [UIColor colorWithWhite:0.5
alpha:0.5];
cell.accessoryType = UITableViewCellAccessoryNone;
return cell;
}
Earthquake *quakeForRow = [appDelegate
objectInListAtIndex:indexPath.row];
[cell setQuake:quakeForRow];
return cell;
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SelectionListCellIdentifier =
@"SelectionListCellIdentifier";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:SelectionListCellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc]
initWithFrame:CGRectZero
reuseIdentifier:SelectionListCellIdentifier] autorelease];
}
NSUInteger row = [indexPath row];
NSUInteger oldRow = [lastIndexPath row];
cell.text = [list objectAtIndex:row];
cell.accessoryType = (row == oldRow && lastIndexPath !=
nil) ? UITableViewCellAccessoryCheckmark :
UITableViewCellAccessoryNone;
return cell;
}- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
int newRow = [indexPath row];
int oldRow = [lastIndexPath row];
if (newRow != oldRow) {
UITableViewCell *newCell = [tableView
cellForRowAtIndexPath:indexPath];
newCell.accessoryType =
UITableViewCellAccessoryCheckmark;
UITableViewCell *oldCell = [tableView
cellForRowAtIndexPath: lastIndexPath];
oldCell.accessoryType =
UITableViewCellAccessoryNone;
lastIndexPath = indexPath;
}
[tableView deselectRowAtIndexPath:indexPath
animated:YES];
}