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種鍵盤消失:點擊鍵盤return鍵,結束編輯
    [_salaryTF addTarget:self action:@selector(endEdit) forControlEvents:UIControlEventEditingDidEndOnExit];
 //事件
 - (void)endEdit
 {
     //不用實現
 }

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

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

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

二、不要將Button添加到ImageView
ImageView的交互性是關閉狀態,無法響應ButtonClick事件。
打開ImageView交互性:

imageView.userInteractionEnabled

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

四、項目錯誤
1.新建項目,莫名的兩個錯誤

解決方案:選擇一個模擬器即可

2.項目無法Build
2.1 Scheme中的名字Homework2與導航中的project名稱Homework_Tax_Teacher’s_0301不一樣
2.2 Run按鈕不可用

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

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

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