第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

難道意思是不能從一個模態(tài)窗口再彈出另一個模態(tài)窗口,不知道如何解決這個問題?

難道意思是不能從一個模態(tài)窗口再彈出另一個模態(tài)窗口,不知道如何解決這個問題?

iOS
子衿沉夜 2023-04-08 15:11:16
在某個UIViewController中出現(xiàn)了這個錯誤,以下是代碼@interface TestViewController : UIViewController <ICALViewDelegate, UIWebViewDelegate,     UIImagePickerControllerDelegate, UINavigationControllerDelegate> {    UIButton *_avatar;    UIImagePickerController *_avatarPicker; }@end- (id)init { ...         _avatar = [[UIButton alloc] initWithFrame:avatarRect];         [_avatar setBackgroundColor:[UIColor blackColor]];         [_avatar addTarget:self action:@selector(pickAvatar:) forControlEvents:UIControlEventAllTouchEvents];         [[self view] addSubview:_avatar];                  _avatarPicker = [[UIImagePickerController alloc] init];        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {             [_avatarPicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];             [_avatarPicker setMediaTypes:[UIImagePickerController availableMediaTypesForSourceType:[_avatarPicker sourceType]]];         }         [_avatarPicker setDelegate:self];         [_avatarPicker setAllowsEditing:YES]; ... } - (void)pickAvatar:(id)sender {     [self presentModalViewController:_avatarPicker animated:YES]; }當(dāng)點擊_avatar這個按鈕時會出現(xiàn)這個錯誤*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <TestViewController: 0x689b2d0>.'*** First throw call stack: (0x149c052 0x172ed0a 0x5ae98d 0x5af58c 0x5af5cc 0xfdbc 0x149dec9 0x4e55c2 0x4e555a 0x58ab76 0x58b03f 0x589290 0x58a49f 0x50aac0 0x50ac56 0x4f1384 0x4ef6cf 0x4ef004 0x4ef682 0x4e4a0f 0x227cfa9 0x14701c5 0x13d5022 0x13d390a 0x13d2db4 0x13d2ccb 0x227b879 0x227b93e 0x4e2a9b 0x1fa8 0x1f05 0x1) terminate called throwing an exception
查看完整描述

1 回答

?
嚕嚕噠

TA貢獻1784條經(jīng)驗 獲得超7個贊

懷疑是

[self presentModalViewController:_avatarPicker animated:YES];

這個時候 _avatarPicker 沒了
建議這樣做

- (id)init
{
...    _avatar = [[UIButton alloc] initWithFrame:avatarRect];
    [_avatar setBackgroundColor:[UIColor blackColor]];
    [_avatar addTarget:self action:@selector(pickAvatar:) forControlEvents:UIControlEventAllTouchEvents];
    [[self view] addSubview:_avatar];        
...
}

- (void)pickAvatar:(id)sender
{
    if (nil == _avatarPicker) {        _avatarPicker = [[UIImagePickerController alloc] init];
        if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypePhotoLibrary]) {
            [_avatarPicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
            [_avatarPicker setMediaTypes:[UIImagePickerController availableMediaTypesForSourceType:[_avatarPicker sourceType]]];
        }
        [_avatarPicker setDelegate:self];
        [_avatarPicker setAllowsEditing:YES];
    }
    [self presentModalViewController:_avatarPicker animated:YES];
}


查看完整回答
反對 回復(fù) 2023-04-11
  • 1 回答
  • 0 關(guān)注
  • 208 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號