iosのサンプルプログラムをまとめ
1.Activity Form
<UIActionSheetDelegate>
– (IBActive) someButtonPressed:(id) sender
{
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:@”Are you sure?”
delegate:self
cancelButtonTitle:@”No way!”
destructiveButtonTitle:@”Yes, I’m Sure!”
otherButtonTitles:nil];
[actionSheet showInView:self.view];
[actionSheet release];
}
2.警告ビュー
<UIAlertViewDelegate>
– (void) actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSInteger) buttonIndex
{
if(buttonIndex != [actionSheet cancelButtonIndex])
{
NSString *message = [[NSString alloc] initWithFormat:@”You can breathe easy, everything went OK.”];
UIAlertView *alert = [[UIAlertView alloc]
initWithTitle:@”Something was done”
message:message
delegate:self
cancelButtonTitle:@”OK”
otherButtonTitles:nil];
[alert show];
[alert release];
[message release];
}
}
3.UITouch 画像をダブルクリックして拡大/復元
if ([touch tapCount] == 2)
{
NSLog(@"%s %d", __FUNCTION__,__LINE__);
if (!flag) {
[bookCover setFrame:CGRectMake(bookCover.frame.origin.x – bookCover.frame.size.width / 2,
bookCover.frame.origin.y – bookCover.frame.size.height / 2,
2 * bookCover.frame.size.width,
2 * bookCover.frame.size.height)];
flag = YES;
}
else {
[bookCover setFrame:CGRectMake(bookCover.frame.origin.x + bookCover.frame.size.width / 4, bookCover.frame.origin.y + bookCover.frame.size.height / 4,
bookCover.frame.size.width / 2, bookCover.frame.size.height / 2)];
flag = NO;
}
}
}
Get the Location of Touches
(CGPoint)locationInView:(UIView *)view
(CGPoint)previousLocationInView:(UIView *)view
view window
Getting Touch Attributes
tapCount(read only) timestamp(read only) phase(read only)
Getting a Touch Object’s Gesture Recognizers
gestureRecognizers
Touch Phase
UITouchPhaseBegan
UITouchPhaseMoved
UITouchPhaseStationary
UITouchPhaseEnded
UITouchPhaseCancelled