2010年10月26日火曜日

あなたが知らないIEの面白い機能

①IEであるHPを開く、(例:http://www.yahoo.co.jp)
②以下のソースをアドレスバーにコピーしてください。

javascript:R=0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI=document.images; DIL=DI.length; function A(){for(i=0; i-DIL; i++){DIS=DI[ i ].style; DIS.position=’absolute’; DIS.left=Math.sin(R*x1+i*x2+x3)*x4+x5; DIS.top=Math.cos(R*y1+i*y2+y3)*y4+y5}R++}setInterval(‘A()’,5); void(0);

③”Enter”キーをクリック

今、面白い場面が見えるでしょう!

※停止したい場合:ページをリフレッシュする

※IEしかできない

Windowsの中どんなファイルでも削除できる方法

ファイルを削除するとき、「このファイルは削除できません」というようなエラーメッセージがよく出会うでしょう。さぁ、いい解決方法を教えるよ

①以下のファイルをメモ帳に書き込んでください


DEL /F /A /Q \\?\%1
RD /S /Q \\?\%1



②XXXX.batの名前で保存してください。例:「superdel.bat」

③削除したいファイルを②で作ったbatファイルのアイコンにドラッグドロップしてください。

ほら、削除できなかったファイルが簡単に削除したよ!

2010年10月20日水曜日

AppStoreを開く

Technical Q&A QA1629Launching the App Store from an iPhone application

Q: How do I launch the App Store from my iPhone application? Also, how do I link to my application on the store?
A: The -[UIApplication openURL:] method handles links to applications and media by launching the appropriate store application
for the passed NSURL object. Follow the steps below to obtain a link to an application, song, or album sold on iTunes,
and link to it from your iPhone application.

1. Launch iTunes on your Mac.

2. Search for the item you want to link to.

3. Right-click or control-click on the item's name in iTunes, then choose "Copy iTunes Store URL" from the pop-up menu.
Note: The returned URL is an itunes.apple.com link. However,
iPhone requires phobosURLs for direct linking to the App Store. Therefore,
you must replace itunes with phobosin the returned URL.

4. Open the modified URL using an NSURL object and the -[UIApplication openURL] method.


See Listing 1 for an example that launches the App Store from a native application.
Listing 1: Launching the App Store from an iPhone application.


NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8";

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:iTunesLink]];




If your application receives iTunes links at runtime—through an RSS feed generated fromhttp://itunes.apple.com/rss, for example—you can modify the URL with your code before opening it, as demonstrated in Listing 2.
Listing 2: Refactoring an iTunes store link at runtime.


NSString *iTunesLink = @"http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=284417350&mt=8";
NSURL *iTunesURL = [NSURL URLWithString:iTunesLink];

// Produce a phobos.apple.com URL that will open the iTunes or App Store application directly
[NSURL URLWithString:[NSString stringWithFormat:@"http://phobos.apple.com%@?%@",
iTunesURL.path, iTunesURL.query]];



Some iTunes links, including iTunes Affiliate links, result in multiple redirections before reaching the appropriate store application.
You can process these redirects silently using NSURLConnection, and open the final URL once the redirects are complete.
This allows your application to transition right to the store without launching Safari.
Listing 3 demonstrates how to accomplish this.


Note: If you have iTunes links inside a UIWebView,
you can use this technique after intercepting the links with the
-[UIWebViewDelegate webView:shouldStartLoadWithRequest:navigationType:] delegate method.

Listing 3:

Processing iTunes Affiliate links in an iPhone application.


// Process a LinkShare/TradeDoubler/DGM URL to something iPhone can handle
- (void)openReferralURL:(NSURL *)referralURL {
NSURLConnection *conn = [[NSURLConnection alloc]
initWithRequest:[NSURLRequest requestWithURL:referralURL]
delegate:self startImmediately:YES];
[conn release];
}

// Save the most recent URL in case multiple redirects occur
// "iTunesURL" is an NSURL property in your class declaration
- (NSURLRequest *)connection:(NSURLConnection *)connection
willSendRequest:(NSURLRequest *)request
redirectResponse:(NSURLResponse *)response {
self.iTunesURL = [response URL];
return request;
}

// No more redirects; use the last URL saved
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[[UIApplication sharedApplication] openURL:self.iTunesLink];
}

指定リンクを開く

[[UIApplication sharedApplication] openURL:[NSURL URLWithString:@“URL....”]];

2010年10月15日金曜日

UITableViewCellのコンテンツをすべて表示できるようにheightの自動調整

#define kCELL_LABEL_FONT [UIFont fontWithName:@"Helvetica-Bold" size:18.0f]
#define kCELL_DESLABEL_FONT [UIFont fontWithName:@"Helvetica" size:12.0f]


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{

NSUInteger row = [indexPath row];

float accesoryWidth = (render.mp_isAccessoryView == NO) ? 0.0f : 30.0f;
CGSize constraintSize = CGSizeZero;
if ([render getSrcImage])
{
constraintSize = CGSizeMake(tableView.frame.size.width - 2.0 * kCELL_DefaultInterval - kCELL_Image_size.width - accesoryWidth,CGFLOAT_MAX);
}
else
{
constraintSize = CGSizeMake(tableView.frame.size.width - 2.0 * kCELL_DefaultInterval - accesoryWidth,CGFLOAT_MAX);
}

CGSize labelSize = [[render getDisplay] sizeWithFont: kCELL_LABEL_FONT constrainedToSize:constraintSize lineBreakMode:UILineBreakModeCharacterWrap];
CGSize detailSize = [[render getDes] sizeWithFont: kCELL_DESLABEL_FONT constrainedToSize:constraintSize lineBreakMode:UILineBreakModeCharacterWrap];

CGFloat result = MAX(44.0, labelSize.height + detailSize.height + 12);

return result;
}

UITableViewCellのImageViewの角丸を実現

cell.imageView.layer.masksToBounds = YES;
cell.imageView.layer.cornerRadius = 5.0f;

※以下のインポートが必要
#import <QuartzCore/QuartzCore.h>

UITableViewCellのImageViewのサイズの設定

画像のサイズを設定すれば、ImageViewのサイズも自動的に変化する。

- (UIImage *)imageScaledToSize:(CGSize)size {
UIGraphicsBeginImageContext(size);
[self drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

return image;
}

2010年10月13日水曜日

UIWebViewのスクロール禁止

UIWebViewのスクロール禁止:
 HTMLファイルのHEADの中に、以下のソースを追加:
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no,minimum-scale=1.0,maximum-scale=1.0"/>

UIWebViewのbouncesの禁止

以下のソースをjavascriptタグに追加:

document.onload = function(){
document.ontouchmove = function(e){ e.preventDefault(); }
}