一、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。