這是因爲你沒有創建一個字符串作爲你的參數。
您可以通過聲明字符串(選項1)或通過在UIAlert視圖(選項2)之外移動字符串創建來解決此問題。
我喜歡對所有字符串使用本地化的字符串(選項3),因爲它可以通過從代碼中獲取字符串來幫助實現字符串重用並輔助國際化。
選項1:
UIAlertView *myAlert=[[UIAlertView alloc]
initWithTitle:@"Logging in"
message:[NSString stringWithFormat:@"you are a member in our website \nWelcome Dear %@ ",UserName.text]
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
選項2:
NSString *alertstr=[NSString stringWithFormat:@"you are a member in our website \nWelcome Dear %@",UserName.text];
UIAlertView *myAlert=[[UIAlertView alloc]
initWithTitle:@"Logging in" message:alertstr
delegate:self
cancelButtonTitle:@"Done"
otherButtonTitles:nil];
選項3:
UIAlertView *myAlert=[[UIAlertView alloc]
initWithTitle:NSLocalizedString(@"Login-title", nil)
message:NSLocalizedString(@"Login-message",nil)
delegate:self
cancelButtonTitle:NSLocalizedString(@"Done", nil)
otherButtonTitles:nil];
這不解決問題。檢查其他答案。 – Garoal