08EndEditing_UIView_bringSubviewToFront/_exchangeSubview_交互性_Lay_Add&Delete_Xcode無法使用的解決方案

一、Homework_Tax_Teacher’s_0301

    //1.文本框,到屏幕中央
    UITextField *salaryTF = [[UITextField alloc]initWithFrame:CGRectMake(self.window.center.x - 100, 60, 200, 40)];
    //中央方法2 center+bounds == fram
    _salaryTF = [[UITextField alloc]init];
    _salaryTF.center = CGPointMake(self.window.center.x, 60);
    _salaryTF.bounds = CGRectMake(0, 0,200,40);

    //2.第2種鍵盤消失:點(diǎn)擊鍵盤return鍵,結(jié)束編輯
    [_salaryTF addTarget:self action:@selector(endEdit) forControlEvents:UIControlEventEditingDidEndOnExit];
 //事件
 - (void)endEdit
 {
     //不用實(shí)現(xiàn)
 }

    //3.拼接字符串
    //stringWithFormat:加號(hào)方法,用類NSString調(diào)用
    NSString *result = [NSString stringWithFormat:@"%.2f元",tax];

二、UIView的刪除和添加(不適合復(fù)雜界面)

- (void)registerAndCommitClick:(UIButton *)button
{
    if (button.tag == 1)
    {
        //從登錄跳轉(zhuǎn)到注冊(cè)
        //方法1(不適合復(fù)雜界面) bringSubviewToFront
        [self.window bringSubviewToFront:_view2];
        
        //方法2(不適合復(fù)雜界面) removeFromSuperview:從界面上移除,內(nèi)存中沒有移除
        [_view1 removeFromSuperview];
        NSLog(@"view1 = %@",_view1);
    }
    if (button.tag == 2)
    {
        //從注冊(cè)跳轉(zhuǎn)到登錄
        //方法1(不適合復(fù)雜界面) bringSubviewToFront
        [self.window bringSubviewToFront:_view1];
        
        //方法2(不適合復(fù)雜界面) addSubview
        [self.window addSubview:_view1];
    }
}
    
    //方法3:交換view1和view2的索引值
    //exchangeSubviewAtIndex
    [self.window exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

二、不要將Button添加到ImageView
ImageView的交互性是關(guān)閉狀態(tài),無法響應(yīng)ButtonClick事件。
打開ImageView交互性:

imageView.userInteractionEnabled

三、系統(tǒng)類文件被修改,Xcode無法使用的解決方案
1.Xcode—>Preference—>Locations—>Derived Data—>進(jìn)入路徑—>刪除默認(rèn)選中的文件夾
2.Product—>Clean

四、項(xiàng)目錯(cuò)誤
1.新建項(xiàng)目,莫名的兩個(gè)錯(cuò)誤

解決方案:選擇一個(gè)模擬器即可

2.項(xiàng)目無法Build
2.1 Scheme中的名字Homework2與導(dǎo)航中的project名稱Homework_Tax_Teacher’s_0301不一樣
2.2 Run按鈕不可用

解決方案:點(diǎn)擊如下圖,選擇Manage Schemes…,點(diǎn)擊Autocrat Scheme Now。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • 初識(shí)iOS APP開發(fā)#### 在iOS APP開發(fā)中, main函數(shù)仍是程序的入口和出口, 但main函數(shù)不需要...
    DeanYan閱讀 6,236評(píng)論 0 3
  • 1,Search Bar 怎樣去掉背景的顏色(storyboard里只能設(shè)置background顏色,可是發(fā)現(xiàn)cl...
    以德扶人閱讀 2,417評(píng)論 2 50
  • //設(shè)置尺寸為屏幕尺寸的時(shí)候self.window = [[UIWindow alloc] initWithFra...
    LuckTime閱讀 832評(píng)論 0 0
  • 使用pacman安裝出現(xiàn)如下錯(cuò)誤:failed to init transaction (unable to lo...
    ikaroskun閱讀 1,457評(píng)論 0 0
  • 今天真的很累,回到家已經(jīng)十點(diǎn)半了,一進(jìn)門我就拿起孩子的作業(yè),檢查數(shù)學(xué)作業(yè)時(shí)發(fā)現(xiàn)有一題做錯(cuò)了,6×6+6=39我...
    金色海洋_c0f4閱讀 147評(píng)論 0 0