我試圖對UIAlertView進行子類化,以更好地處理我的應用中的錯誤狀態。麻煩時遇到與otherButtonTitles無終止的參數,當我創建我的子類,它只是拿起在列表中的第一個字符串,而不是所有的字符串UIAlertView的子類化
+ (ErrorAlertView *)displayErrorAlertViewWithTitle:(NSString *)title
message:(NSString *)message
delegate:(id<UIAlertViewDelegate>)delegate
errorDelegate:(id<ErrorAlertViewDelegate>)errorDelegate
cancelButtonTitle:(NSString *)cancelButtonTitle
displayNow:(BOOL)displayNow
tag:(NSUInteger)tag
otherButtonTitles:(NSString *)otherButtonTitles, ...;
{
ErrorAlertView *errorAlertView = [[ErrorAlertView alloc] initWithTitle:title
message:message
delegate:delegate
cancelButtonTitle:cancelButtonTitle
otherButtonTitles:otherButtonTitles, nil];
errorAlertView.errorDelegate = errorDelegate;
errorAlertView.tag = tag;
if (displayNow) {
[errorAlertView show];
}
return [errorAlertView autorelease];
}
如果我提出以下撥打以上方法:
[ErrorAlertView displayErrorAlertViewWithTitle:[self noInternetConnectionAlertViewTitle]
message:[self noInternetConnectionAlertViewMessage]
delegate:self
errorDelegate:errorDelegate
cancelButtonTitle:@"OK"
displayNow:YES
tag:ErrorAlertTagInternetConnectionError
@"Try again",@"Setting", nil];
顯示的UIAlertView只顯示@「Try again」按鈕。
[目的-C繞過...零終止參數列表(可能重複http://stackoverflow.com/questions/2345196/objective-c-passing-around-nil-終止參數列表) –