它是一個單視圖應用程序,我只需在它上面添加一個按鈕,當我點擊按鈕時,它會顯示按鍵板。 並且我無法在onBtn函數中自動釋放TSAlertView。誰能告訴我爲什麼,我真的很困惑。ios5,TSAlertView不會彈出,誰能告訴我爲什麼?
- (void)viewDidLoad
{
[super viewDidLoad];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
btn.frame = CGRectMake(30, 30, 100., 50);
[btn setTitle:@"Test" forState:UIControlStateNormal];
[btn addTarget:self action:(@selector(onBtn:)) forControlEvents: UIControlEventTouchUpInside];
[btn setBackgroundColor:UIColor.greenColor];
[self.view addSubview:btn];
}
-(void)onBtn:(id)sender{
TSAlertView* av = [[TSAlertView alloc] init];
av.title = @"Test";
av.message = @"This is a test";
[av addButtonWithTitle:@"cancel"];
[av addButtonWithTitle:@"rename"];
av.style =TSAlertViewStyleInput;
av.buttonLayout = TSAlertViewButtonLayoutNormal;
av.usesMessageTextView =NO;
av.width = 0.0;
av.maxHeight = 0.0;
[av show];
}
TSAlertView默認爲普通視圖。代碼中必須有其他內容導致此問題。你能顯示你的onBtn方法的其餘部分嗎? – TigerCoding
@Havt我已經發布了onBtn方法的其餘部分,請給我一隻手,謝謝 –
鍵盤出現是因爲一些想要鍵盤的UI對象成爲第一響應者。 –