在 iOS6 以前,會使用以下方法來顯示輸入框:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Enter
Password" message:@"" delegate:self cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Ok", nil];
UITextField *myTextField = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[myTextField setSecureTextEntry:YES]; //輸入內容為密碼
[alert addSubview:myTextField];
[myTextField release];
但在 iOS7 以後,addSubview 函式不支援了,要改統一使用以下方法:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Enter Password" message:@"" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
alertView.alertViewStyle = UIAlertViewStyleSecureTextInput; //輸入內容為密碼
UITextField *myTextField = [alertView textFieldAtIndex:0];
[alertView show];
2013年10月29日 星期二
2013年10月16日 星期三
[iOS] 測試 InApp 時,出現無法連接 iTunes Store 的錯誤時處理小記
每次測試 InApp 總讓我有新的注意事項,發現取得付費資訊正常。
但按下確認要輸入帳號資訊時,一直出現"無法連接 iTunes Store"的錯誤訊息。
結果才發現,要先把設定裡的 apple id 登出,才可使用。
或者直接登入在 iTunes Connect 裡建立好的 tester 帳號亦可。
但按下確認要輸入帳號資訊時,一直出現"無法連接 iTunes Store"的錯誤訊息。
結果才發現,要先把設定裡的 apple id 登出,才可使用。
或者直接登入在 iTunes Connect 裡建立好的 tester 帳號亦可。
2013年10月10日 星期四
[iOS] 如何設定 SearchBar 背景色
在 iOS6 以前,加入以下方法即可。
for(UIView *subview in searchBar.subviews)
{
if([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
{
[subview removeFromSuperview];
break;
}
}
但在 iOS7 中,要再加下以下方式才可以。
[searchBar setBarTintColor:[UIColor clearColor]];
for(UIView *subview in searchBar.subviews)
{
if([subview isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
{
[subview removeFromSuperview];
break;
}
}
但在 iOS7 中,要再加下以下方式才可以。
[searchBar setBarTintColor:[UIColor clearColor]];
訂閱:
文章 (Atom)