Posts tagged iPhone
[iPhone 開発メモ] iPhone のホーム画面のような UI を作る
1iPhone のホーム画面はフリックして左右のページに移動でき、また下にある白い点(ページコントロール)をタップしても移動できます。

iPhone のホーム画面
こういう UI を作ってみました。
(続きを読む…)
[iPhone 開発メモ] UIScrollView でピンチイン・ピンチアウトで拡大縮小する
3昨日のUIScrollView でスクロールさせるに少し追加して UIScrollView をピンチイン、ピンチアウトで拡大縮小する方法です。
ScrollViewController.m の scrollView の設定をしている部分に以下を追加。拡大率と縮小率の指定です。
scrollView.maximumZoomScale = 4.0; scrollView.minimumZoomScale = 0.4;
[iPhone 開発メモ] UIScrollView でスクロールさせる
10大きな画像を表示してそれを自由にスクロールさせる方法
今回はあらかじめ imgname.jpg という画像ファイルを Resource に入れておいてそれを表示させてスクロールさせています。
ViewBased のアプリを新規で作成、名前を「Scroll」とする。
ScrollViewController.h
@interface ScrollViewController : UIViewController{ IBOutlet UIScrollView *scrollView; UIImageView *myImage; } @property (nonatomic, retain) UIScrollView *scrollView; @property (nonatomic, retain) UIImageView *myImage; @end
[iPhone 開発メモ] アプリ内で UIWebView を使って Web ページを表示する
7iPhoen アプリ内で Web ページを表示する方法です。UIWebView を使います。
UIWebViewを表示するためのシンプルなUIViewController – ちびり文
こちらのエントリを参考に IB を使ってやってみました。
(続きを読む…)
[iPhone 開発メモ] アプリから URL を指定して Web ページを Safari で開く
0アプリから URL を指定して Safari で開く方法
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"http://www.syuhari.jp/blog"]];
[iPhone 開発メモ] 本体の回転を検知する
1iPhone を横方向に回転させた時に検知する方法のメモです。
-(void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)FromInterfaceOrientation {
if(FromInterfaceOrientation == UIInterfaceOrientationPortrait){
// 横向き
} else {
// 縦向き
}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
[iPhone 開発メモ] 警告画面の表示
3iPhone アプリで警告画面を表示させる方法です。
警告画面を表示する
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@"Alert Test"
message:@"Message!!\nThis is Alert Test."
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"One", @"Two", nil];
[alert show];
[alert release];
[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;
The iPhone Developer’s Cookbook 購入
0以前から読みたかった「The iPhone Developer’s Cookbook」を購入しました。なぜかアマゾンで購入できなくなったり、予約販売になったりと不思議な本ですが、先日違う本を購入しようとしたときに、購入可能だったので急いで購入しました。今見たらまた予約販売になっていた。
(続きを読む…)
[iPhone] XML を NSXMLParser を使用して解析する
1iPhone では NSXMLDocument がシュミレータでは動作するが実機では動作しないそうなので、NSXMLParser を使用して解析してみました。
解析したのは下記のような XML です。
<?xml version="1.0" encoding="UTF-8"?>
<users>
<user name="hoge" age="20" />
<user name="fuga" age="30" />
</users>