只需要在"Info.plist"中的"Status bar is initially hidden"設定為YES,在啟動App同時就可以有沒有狀態列的啟動畫面
把Youtube換成新版面
目前僅支援Firefox、Chrome
在firefox按下: Ctrl + Shift + K (Win) | Cmd + Shift + K (Mac)
在Chrome按下: Ctrl + Shift + J (Win) | or Cmd + Alt + J (Mac)
切換到console並輸入以下文字,再按下enter(可參考下圖,以chrome為例)
document.cookie="VISITOR_INFO1_LIVE=ST1Ti53r4fU";
重新整理後所看到就是新版面啦!
by
Isken Huang
-
11/22/2011
0
回應
-
[ Web ]
iOS UIActionSheet
UIActionSheet在部份選單中還蠻好用的,其中如果有不需要的按鈕只要將String部份輸入為"nil"按鈕就會自動消失了!
UIActionSheet *myActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"cancel" otherButtonTitles:@"AAA", @"BBB", @"CCC", @"DDD", nil];
myActionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
[myActionSheet showInView:self.view];
使用時如果有需要知道按下的按鈕是哪一個記得在.h檔中加入"UIActionSheetDelegate",並在.m檔中加入以下Delegate,"buttonIndex"就是由上往下算的按鈕數目,從"0"開始。
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
NSLog(@"buttonIndex = %d", buttonIndex);
}
相關連結
iOS Developer Library
iOS Developer Library - UIActionSheet
iOS UIWebView loadRequest
這在iOS中算是蠻常用的東西,不過我每次用完就忘了,在這Memo一下。
其中因為WebView放在ViewController內,所以使用"self.view.frame"來取得CGRect
UIWebView *myWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"URL Here!"]];
[myWeb loadRequest:request];
[self.view addSubview:myWeb];
如果需要在NavigationController內直接push出一個ViewController請使用以下方式
UIViewController *myViewController = [[UIViewController alloc] init];
UIWebView *myWeb = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, myViewController.view.frame.size.width, myViewController.view.frame.size.height)];
NSURLRequest *request = [[NSURLRequest alloc] initWithURL:[NSURL URLWithString:@"URL Here!"]];
[myWeb loadRequest:request];
[myViewController.view addSubview:myWeb];
[self.navigationController pushViewController:myViewController animated:YES];
相關連結
iOS Developer Library
iOS Developer Library - UIWebView Class Reference
iOS UITableView update cell 更新TableViewo單一cell內容
tableView 真的是iOS中相當關鍵的一個UI,一方面是列表方式在呈現資料可以說是最好的方式,讓使用者快速得到想要的資訊,在其中也因用途不同需要客製化的部份相當多,就如下面要介紹的更新單一cell。
以下myTableView為UITableView的名稱
//更新指定cell
NSIndexPath *path = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
NSArray *myArray = [NSArray arrayWithObjects:path, nil];
[myTableView reloadRowsAtIndexPaths:myArray withRowAnimation:UITableViewRowAnimationFade];
如果需要更新所按下的cell可以搭配UITableViewDelegate使用
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSIndexPath *a = [NSIndexPath indexPathForRow:indexPath.row inSection:indexPath.section];
NSArray *my = [NSArray arrayWithObjects:a, nil];
[myTableView reloadRowsAtIndexPaths:my withRowAnimation:UITableViewRowAnimationFade];
}
其中UITableViewRowAnimation有相當多的動畫方式可以使用,當然也可以不要動畫,只要在"withRowAnimation:"輸入"UITableViewRowAnimationNone"即可達到直接修改cell並且無動畫。
NSArray的部份也可以一次加入多個需要更新的cell,如果是需要一次更新所有的cell可以使用以下方式
[myTableView reloadData]
相關連結
iOS Developer Library
iOS Developer Library - UITableView Class Reference
iOS navigation to the address 導航到指定地址
Google的導航真的很好用,在iOS上Google Maps的使用方式也比起在Android上好用很多,光是要申請KEY,還需要弄一堆有的沒的就夠麻煩了,這邊就來解說一下如何使用iOS的Maps導航功能,順便就將寫成了個function來方便使用。
-(void)navivationToTheAddress:(NSString *)address{
//導航起點的經緯度
NSString* myLatitude = @"0.0";
NSString* myLongitude = @"0.0";
NSString* urlString = [NSString stringWithFormat:@"http://maps.google.com/maps?f=d&source=s_d&saddr=%@,%@&daddr=%@", myLatitude, myLongitude, address];
//將地址的中文轉碼
NSString *escaped = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
//開啟Maps導航
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:escaped]];
}
相關連結
iOS Developer Library
iOS UITableView cell and section height
TableView在iOS4所寫相同的Code,在iOS5 build起來卻有不同的結果,最後找出原因在iOS4以前TableView預設的section高度為0(簡單來說就是看不到),但在iOS5卻為預設高度(好像是20,剛好一行字)。上架(Apple Store)後並不會出現這問題,所以若已經確定為上架版本可以放心。
iOS5上需要特別去修正過section的高度來讓他消失,此function回傳值即為section的高度。
//section height
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 0.0;
}
修改Cell高度即為
//cell height
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;{
//set cell size
return 100.0;
}
相關連結
iOS Developer Library
iOS Developer Library - UITableView
iOS Developer Library - UITableViewController
iOS UITableView seleted blue background
TableView預設在點選同時會產生藍色的背景作為Highlight,在某些狀況這是好事,可以清楚的標示出目前所點到的那行,但部份狀況下是不需要他的,其實只要簡單的一行就可以讓他消失掉。
只需要在UITableView的Delegate內加入這行,也就是下面這function內加入
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {}
// cell 為cell的名稱,也就是所定義的"UITableViewCell *cell"
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];相關連結
iOS Developer Library
iOS Developer Library - UITableView
iOS Developer Library - UITableViewController



